How to save a column of strings into a NetCDF file?
Show older comments
If I have a one-column data with a dimension of 200x1 (e.g., Longitude as in the below example), I know how to store them into a NetCDF file by following the below script:
%% define the dimensions:
dim = netcdf.defDim(ncid, 'data_grid', 200);
%% define the variable and variable attributes:
Var_Longitude = netcdf.defVar(ncid, 'LONGITUDE', 'double', dim);
netcdf.putAtt(ncid, Var_Longitude, 'long_name', 'Longitude in decimal degrees');
netcdf.putVar(ncid, Var_Longitude, Longitude);
What if I have a one-column text string with a dimension of 200x1? For example, the string matrix could be like this:
"test1"
"test2"
"test56"
...
Just change the 'double' to 'string"? Anything else I need to change?
Accepted Answer
More Answers (0)
Categories
Find more on NetCDF in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!