Syntax
data = cdfread(file)
data = cdfread(file, 'records', recnums, ...)
data = cdfread(file, 'variables', varnames, ...)
data = cdfread(file, 'slices', dimensionvalues, ...)
[data, info] = cdfread(file, ...)
Description
data = cdfread(file)
reads all of the variables from each record of the Common Data Format (CDF) file specified in the string, file
. The return value, data
, is a cell array in which each row contains a record and each column represents a variable.
data = cdfread(file, 'records', recnums, ...)
reads only those records specified in the vector, recnums
. The record numbers are zero-based. The return value, data
, is a cell array having length(recnums)
number of rows and as many columns as there are variables.
data = cdfread(file, 'variables', varnames, ...)
reads only those variables specified in the 1-by-N or N-by-1 cell array of strings, varnames
. The return alue, data
, is returned in a cell array having length(varnames)
number of columns and a row for each record requested.
data = cdfread(file, 'slices', dimensionvalues, ...)
reads specific values from the records of one variable in the CDF file. The N-by-3 matrix, dimensionvalues
, indicates which records are to be read by specifying start
, interval
, and count
parameters for each of the N dimensions of the variable. The start
parameter is zero-based.
The number of rows in dimensionvalues
must be less than or equal to the number of dimensions of the variable. Unspecified rows default to [0 1 N]
, where N
is the total number of values in a record. This causes cdfread
to read every value from those dimensions.
Because you can read just one variable at a time, you must also include a 'variables'
parameter with this syntax.
[data, info] = cdfread(file, ...)
also returns details about the CDF file in the info
structure.
Examples
Read all of the data from the file.
Read just the data from variable 'Time'
.
Read the first value in the first dimension, the second value in the second dimension, the first and third values in the third dimension, and all values in the remaining dimension of the variable 'multidimensional'
.
data = cdfread('example.cdf', 'Variable', ...
{'multidimensional'}, 'Slices', [0 1 1; 1 1 1; 0 2 2]);
This is similar to reading the whole variable into 'data'
, and then using the MATLAB command
cdfwrite
Syntax
cdfwrite(file, variablelist)
cdfwrite(..., 'PadValues', padvals)
cdfwrite(..., 'GlobalAttributes', gattrib)
cdfwrite(..., 'VariableAttributes', vattrib)
cdfwrite(..., 'WriteMode',mode
)
cdfwrite(..., 'Format',format
)
Description
cdfwrite(file,variablelist)
writes out a Common Data Format (CDF) file, specified in the string, file
. The variablelist
argument is a cell array of ordered pairs, which are comprised of a CDF variable name (a string) and the corresponding CDF variable value. To write out multiple records for a variable, put the values in a cell array, where each element in the cell array represents a record.
cdfwrite(...,'PadValues',padvals)
writes out pad values for given variable names. padvals
is a cell array of ordered pairs, which are comprised of a variable name (a string) and a corresponding pad value. Pad values are the default value associated with the variable when an out-of-bounds record is accessed. Variable names that appear in padvals
must appear in variablelist
.
cdfwrite(...,'GlobalAttributes',gattrib)
writes the structure gattrib
as global metadata for the CDF file. Each field of the structure is the name of a global attribute. The value of each field contains the value of the attribute. To write out multiple values for an attribute, put the values in a cell array where each element in the cell array represents a record.
cdfwrite(..., 'VariableAttributes', vattrib)
writes the structure vattrib
as variable metadata for the CDF. Each field of the struct is the name of a variable attribute. The value of each field should be an M-by-2 cell array where M is the number of variables with attributes. The first element in the cell array should be the name of the variable and the second element should be the value of the attribute for that variable.
cdfwrite(...,'WriteMode',
where mode
) mode
is either 'overwrite'
or 'append'
, indicates whether or not the specified variables should be appended to the CDF file if the file already exists. By default, cdfwrite
overwrites existing variables and attributes.,
cdfwrite(...,'Format',
where format
) format
is either 'multifile'
or 'singlefile'
, indicates whether or not the data is written out as a multifile CDF. In a multifile CDF, each variable is stored in a separate file with the name *.vN
, where N
is the number of the variable that is written out to the CDF. By default, cdfwrite
writes out a single file CDF. When 'WriteMode'
is set to 'Append'
, the 'Format'
option is ignored, and the format of the pre-existing CDF is used.
Examples
Write out a file 'example.cdf'
containing a variable 'Longitude'
with the value [0:360]
.
Write out a file 'example.cdf'
containing variables 'Longitude'
and 'Latitude'
with the variable 'Latitude'
having a pad value of 10 for all out-of-bounds records that are accessed.
Write out a file 'example.cdf'
, containing a variable 'Longitude'
with the value [0:360]
, and with a variable attribute of 'validmin'
with the value 10.
varAttribStruct.validmin = {'longitude' [10]};
cdfwrite('example', {'Longitude' 0:360}, 'VarAttribStruct',...
varAttribStruct);
Syntax
Description
B = ceil(A)
rounds the elements of
A
to the nearest integers greater than or equal to A
. For complex A
, the imaginary and real parts are rounded independently.
Examples
No comments:
Post a Comment