How to save character matrix into NetCdf files?
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hi everyone, I have character matrix A1
A1='101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
    '101670  '
I am trying to save it into a netcdf file using ncreate and ncwrite. 
nccreate('file_name.nc','A1',...
         'Dimensions', {'x',size(A1,1),'y',size(A1,2)},...
         'FillValue','disable');     
ncwrite(file_name,'A1',A1);
But It is showing some error releted to conversion of between text and number.
Error using netcdflib
The NetCDF library encountered an error during execution of 'putVaraText' function -
'Attempt to convert between text & numbers (NC_ECHAR)'.
Error in netcdf.putVar (line 84)
netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/write (line 844)
                netcdf.putVar(gid, varid,start, count, varData);
Error in ncwrite (line 75)
ncObj.write(varName, varData, start, stride);
Can someone help me how to save the character matrix into netcdf file?
0 件のコメント
採用された回答
  Walter Roberson
      
      
 2022 年 8 月 3 日
        The default data type is double. You need the "datatype" option.
Please recheck what x and y mean to you. You are using x as height of the matrix, but by convention y is height.
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で NetCDF についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

