필터 지우기
필터 지우기

How can I write missing value ncwriteatt

조회 수: 3 (최근 30일)
Farshid Daryabor
Farshid Daryabor 2024년 2월 3일
답변: Walter Roberson 2024년 2월 6일
I created a netcdf file with attributes correctly, but I tried to add also missing value (1.0000e+20) as number to variabel attribute part, I encountering with error. Does anyone know where my mistake is so that I can correct it. I tried below command.
missing_value = 1.0000e+20;
missing = string(missing_value);
ncwriteatt(outputfile,'salinity','missing_value','missing')
Error using netcdflib
The NetCDF library encountered an error during execution of 'putAttText'
function - 'Not a valid data type or missing_value type mismatch (NC_EBADTYPE)'.
Thanks!
  댓글 수: 2
Walter Roberson
Walter Roberson 2024년 2월 3일
ncwriteatt(outputfile,'salinity','missing_value',missing)
would be more likely.
... But I suspect that you want
ncwriteatt(outputfile,'salinity','missing_value',single(missing_value))
Farshid Daryabor
Farshid Daryabor 2024년 2월 3일
Thanks!
What about 'NaN' value as missing_value, it should be;
ncwriteatt(outputfile,'salinity','missing_value',single(NaN))

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2024년 2월 6일
You cannot set the _FillValue of a variable after the variable is created.
FillValueReplacement value for missing values
scalar | "disable"
Replacement value for missing values, specified as a scalar or "disable". The default value is supplied by the netCDF library. To disable replacement values, specify a value of "disable". You cannot disable FillValue when writing string data to files with format netcdf4.
Note
The nccreate function assigns the value of FillValue to the _FillValue attribute of the new netCDF variable varname. You cannot change the value of this attribute after you have created the variable.
This argument is available only for files with format netcdf4 or netcdf4_classic.

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by