フィルターのクリア

How can I convert back the _FillValue elements from zero to NaN

1 回表示 (過去 30 日間)
Szabó-Takács Beáta
Szabó-Takács Beáta 2015 年 8 月 19 日
I have A matrix which contains NaN as a _FillValues and inf values. I wanted to convert the inf values to zero by:
A(~isfinite(A)) = 0.
This function changed the NaN values to zero. I tried get back NaN values by the following functions:
A(isnan(A)) = nan
A(A == attval3) = nan
But the NaN values remain zero. How can I convert back the _FillValue elements to NaN?

回答 (1 件)

Guillaume
Guillaume 2015 年 8 月 19 日
Well, once you've replaced the NaNs in A by 0, isnan(A) is never going to find any NaN. Unless you've kept a copy of the original A around there's no way to find out where they were.
To replace just the Inf and not the NaN in the unmodified, original A, use isinf:
A(isinf(A)) = 0; %or A(~isnan(A) & ~isfinite(A))
  1 件のコメント
Szabó-Takács Beáta
Szabó-Takács Beáta 2015 年 8 月 20 日
Thank you Guillaume very much for help! It works.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by