[netcdf-java] Problem in Sample data in NetCDF

Hello,

I'm working with Java nc2 library and I wish to read Etopo files (which are in NetCDF format) with the methods of the library. I work with MatLab R2006b. I want to sample the data in Latitude and Longitude, ie, I don't want to read all the data but only two samples among 4.

In Java, I manage to read it with loop in latitude and longitude but it isn't satisfied by the process time which is more longer than the version with mex version.

Do you know a method with Java which is so faster than with mex functions ?

Thank you by advance.

Roger GALLOU
France

PS:
I join here my example code for it in the two versions :
Mex and Java.

function test_SampleNetCDF_mex(nomFic)
%
nc = netcdf(nomFic);
if isempty(nc)
  return
end

indLat = 1:2:3;
indLon = 2:2:4;
Z = nc{'MEAN_VALUE'}(indLat, indLon)


close(nc)

%%
function test_SampleNetCDF_java(nomFic)

import ucar.nc2.*;
import ucar.ma2.*;

idFile = NetcdfFile.open(nomFic);
if isempty(idFile)
  return
end

dataVar = idFile.findVariable('MEAN_VALUE');
indLat = 1:2:3;
indLon = 2:2:4;
Z = zeros(size(indLat, 2), size(indLon, 2));
for latLoop=1:numel(indLat)
   dummy= dataVar.slice(0,indLat(latLoop));
   dummy2 = pppp.read;
   for lonLoop=1:numel(indLon)
       dummy23= dummy2.slice(0,indLon(lonLoop));
       Z(latLoop, lonLoop) = dummy3.copyTo1DJavaArray;
   end
end

idFile.close();