1 function var=ncdump(filename,varname)
3 % get the list of all variables and print their info
5 % var=ncdump(filename,'-q')
6 % get the list of all variables quietly
8 % var=ncdump(filename,varname)
9 % read one variable in its native form and its info
10 % (use ncread to read a variable as a Matlab matrix)
12 % filename the name of netcdf file
13 % varname the name of a variable in the file
14 % var returned structure with fields describing the variable
16 % if varname not given:
17 % get info for all variables in the netcdf file
19 % if varname is given and string:
20 % get structure with attributes and value for one variable
22 % if varname is a cell array, return array of structures of the same shape
25 % Jan Mandel, September 2008
26 % developed from an earlier code by Jon Beezley
28 if ~exist('varname','var'),
32 if strcmp(varname,'-q'),
33 var=nclist(filename,'-q');
35 var=ncvar(filename,varname);
37 elseif iscell(varname),
38 for j=size(varname,2):-1:1,
39 for i=size(varname,1):-1:1,
40 var(i,j)=ncvar(filename,varname{i,j});
44 varname,error('unsupported type')