substituting value in matrix does not work for some reason
Ältere Kommentare anzeigen
A = [6 9 NaN NaN 8 NaN]; B = [2 5 342 232 1 116];
sizeA = size(A);
for m = [1:1:size(2)];
if A(1,m) == NaN;
B(1,m) = NaN;
end;
end;
I was hoping B would become [2 5 NaN NaN 8 NaN], but it did not change. I would appreciate any help
Akzeptierte Antwort
Weitere Antworten (1)
Kevin Claytor
am 18 Nov. 2014
Logical indexing makes this much easier;
B(A==NaN) = NaN;
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!