Find and replace missing value in a 1*1 struct with 34 fields

I have a 1*1 struct with 34 fields. every field is a 3d array by itself. A picture of it attached. I want to have a code to find -9.969209968386869e+36 in everywhere of this struct (including inside fields) and replace it with NaN.
thank you

1 件のコメント

Daniel M
Daniel M 2019 年 10 月 28 日
編集済み: Daniel M 2019 年 10 月 28 日
help structfun
is the first place to start.

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

 採用された回答

Image Analyst
Image Analyst 2019 年 10 月 28 日

1 投票

How about (untested)
% Get all the field names with this structure.
fieldNames = fieldnames(precip)
for k = 1 : length(fieldNames)
thisFieldName = fieldNames{k}; % Get this field name.
thisField = precip.(thisFieldName); % Get the 3-D array.
% Use ismembertol() to look for the specified value.
indexes = ismembertol(thisField, whatever)
% Replace those locations with nans.
thisField(indexes) = nan;
% Put back into precip.
precip.(thisFieldName) = thisField;
end

2 件のコメント

BN
BN 2019 年 10 月 28 日
編集済み: BN 2019 年 10 月 28 日
thanks but it says
Out of memory. Type "help memory" for your options
I even try to increase RAM in preference but didn't work
Image Analyst
Image Analyst 2019 年 10 月 29 日
Attach precip in a .mat file
save('answers.mat', 'precip');
then attach 'answers.mat' with the paper clip icon.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

BN
2019 年 10 月 28 日

コメント済み:

2019 年 10 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by