How do you turn values in column A to NaN if values in column B are zero?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Matthew Brown
am 19 Nov. 2021
Kommentiert: Matthew Brown
am 19 Nov. 2021
If column B is 0 turn column 1 to nan
So, it would turn something like this:
[37370 1
37421 0
25021 1
63453 1
25467 0
36511 0
37341 1
50508 0
28250 1]
Into this:
[37370 1
nan 0
25021 1
63453 1
nan 0
nan 0
37341 1
nan 0
28250 1]
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 19 Nov. 2021
% If A and B are separate column vector variables:
A(B==0) = nan;
% or for an N-by-2 matrix m
rowsToChange = m(:, 2) == 0;
m(rowsToChange, 1) = nan;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!