Replace values in grid data (3D) to NaN, like another (3D) have NaN

9 ビュー (過去 30 日間)
nada
nada 2020 年 8 月 6 日
コメント済み: Walter Roberson 2021 年 2 月 1 日
Hi to all
I have grid data VWind=300*16*21 and
SST=300*16*21 have NaN values
How i can to the ​​replace NaN value at VWind data to the same location in SST data
Thanks in advance

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020 年 8 月 6 日
It can be done very easily with a logical indexing opt: e.g.:
Index = isnan(SST);
VWind(Index)=NaN;
Now you can compare and verify the elements of SST and VWind using sum() operator, for instance.
Good luck.
  3 件のコメント
James Karden
James Karden 2021 年 2 月 1 日
How could I get this to loop over each time step (let's say over 40 years) if I have a matrix of lat x lon x time?
Walter Roberson
Walter Roberson 2021 年 2 月 1 日
If SST is 3D then you would not normally work by timestep: you would normally just do
VWind(isnan(SST)) = NaN;
If you need to work timestep by timestep for some reason, then see https://www.mathworks.com/matlabcentral/answers/731168-extract-specific-data-from-3d-matrix#answer_610468 for some ways in which you can extract information slice by slice.

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

その他の回答 (1 件)

Sudheer Bhimireddy
Sudheer Bhimireddy 2020 年 8 月 6 日
I don't know if I understood your question properly, but here goes:
If you have NaN values in SST matrix and would like to replace VWind values to NaN wherever SST(i,j,k)=NaN:
VWind(isnan(SST)) = nan;
Similarly if VWind already has NaNs, to make corresponding indices of SST to NaN:
SST(isnan(VWind)) = nan;
If you run both these commands, then both your matrices will have same number of NaN values at same locations.
Hope this helps.
  2 件のコメント
nada
nada 2020 年 8 月 6 日
very thanks
James Karden
James Karden 2021 年 2 月 1 日
How could I get this to loop over each time step (let's say over 40 years) if I have a matrix of lat x lon x time?

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

カテゴリ

Help Center および File ExchangeInterpolation of 2-D Selections in 3-D Grids についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by