Replace missing value of cell array with NaN

please find attached file, I tried to replace missing values (-1.27605887595352e+39) with NaN, unfortunately I encountering with the following error. Thanks in advance any help.
INDEX = cellfun(@(x) (x<-1),presglb,'UniformOutput',false) ;
>> presglb_new = presglb(INDEX);
Function 'subsindex' is not defined for values of class 'cell'.

 採用された回答

Bhaskar R
Bhaskar R 2020 年 2 月 11 日
編集済み: Bhaskar R 2020 年 2 月 11 日

1 投票

ind = cellfun(@(x) (x<-1),presglb,'UniformOutput',false);
for ii =1 :length(presglb)
presglb{ii}(ind{ii}) = nan;
end

7 件のコメント

Farshid Daryabor
Farshid Daryabor 2020 年 2 月 11 日
"ind" is corresponding to what?
Farshid Daryabor
Farshid Daryabor 2020 年 2 月 11 日
is corresponding to the element below?
ind = cellfun(@(x) (x<-1),presglb,'UniformOutput',false) ;
Bhaskar R
Bhaskar R 2020 年 2 月 11 日
Forgot to mention, now post is edited.
Farshid Daryabor
Farshid Daryabor 2020 年 2 月 11 日
Yes, I got it thanks
Bhaskar R
Bhaskar R 2020 年 2 月 11 日
You are welcom :-)
Farshid Daryabor
Farshid Daryabor 2020 年 2 月 11 日
Dear Bhaskar, after getting new presglb, you know how can I remove NaN?
Thanks
Farshid Daryabor
Farshid Daryabor 2020 年 2 月 11 日
I know the following way, but the double size in the cell has changed, I want to keep the size as before.
>> result = cellfun(@(x) x(~isnan(x)), presglb, 'Uniform', 0);

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

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by