Convert zeros to NAN

2 Ansichten (letzte 30 Tage)
Nancy
Nancy am 14 Jun. 2011
I have a matrix (N rows and M columns). It consists of integer values. I want to convert all the zero values from rows 1:N and columns 3:M to NaN. Is there any way to do so.
Thanks, Nancy

Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 14 Jun. 2011
One of many ways
idx = ~A;
idx(:,1:2) = false;
A(idx) = nan;
  3 Kommentare
Sean de Wolski
Sean de Wolski am 14 Jun. 2011
Yes. It sets any value that was a zero value (the ~ (not) command) in the first definition to be false so that it doesn't show up in the nan assignment.
Nancy
Nancy am 14 Jun. 2011
Thanks. :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Numeric Types finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by