Replace missing value of cell array with NaN

25 views (last 30 days)
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'.

Accepted Answer

Bhaskar R
Bhaskar R on 11 Feb 2020
Edited: Bhaskar R on 11 Feb 2020
ind = cellfun(@(x) (x<-1),presglb,'UniformOutput',false);
for ii =1 :length(presglb)
presglb{ii}(ind{ii}) = nan;
Farshid Daryabor
Farshid Daryabor on 11 Feb 2020
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);

Sign in to comment.

More Answers (0)


Find more on Data Types in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by