Please how can I convert the some values of my cell array from 0 to NaN

4 views (last 30 days)
Hi all,
I am intermediate user of MATLAB - I understand the basics and just a bit more.
I have a 43 x 25 cell array, having matrices of various sizes in each cell (for example: 2000 x 61, 4000 x 61 and others of approximate size). Some of these matrices have zero values that I need to convert to NaN.
Please I would appreciate your help.

Answers (2)

Andrei Bobrov
Andrei Bobrov on 22 Oct 2018
A - your cell array.
for ii = 1:numel(A)
A{ii}(A{ii} == 0) = nan;
end

madhan ravi
madhan ravi on 22 Oct 2018
Edited: madhan ravi on 22 Oct 2018
An example:
a={zeros(1,12)}
a=cell2mat(a)
a(a==0)=NaN
a={a}
celldisp(a)

Categories

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!