On Thu, Apr 29, 2010 at 1:23 PM, xnand <address@hidden> wrote:
Hi everyone.
The following code creates a netcdf file and then isempty checks if
it is
empty. But though it is not empty, it shows the file as empty.
latitude = -90:1:90;
longitude = -179:1:180;
[y,x] = meshgrid(pi/180 * latitude,pi/180 * longitude);
temp = cos(2*x) .* cos(y);
nc = netcdf('example.nc','c');
nc('longitude') = 360;
nc('latitude') = 181;
nc{'longitude'} = ncdouble('longitude');
nc{'longitude'}(:) = longitude;
nc{'longitude'}.units = 'degree West';
nc{'latitude'} = ncdouble('latitude');
nc{'latitude'}(:) = latitude;
nc{'latitude'}.units = 'degree North';
nc{'temp'} = ncdouble('longitude','latitude');
nc{'temp'}(:) = temp;
nc{'temp'}.units = 'degree Celsius';
nc{'temp'}.valid_range = [-10 40];
ncclose(nc);
if isempty(nc)
disp(' ## The file is empty.')
end
Please note, netcdf function is from octcdf package.
isempty is not supposed to work with netcdf file objects. To test is a
file is empty you can use dir:
d = dir('somefile')
if d.bytes == 0
end
Cheers,
Alex
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave