How do I use if with the value of the array is a string?

1 Ansicht (letzte 30 Tage)
Hang Vu
Hang Vu am 4 Mai 2019
Kommentiert: Hang Vu am 4 Mai 2019
I want to check if the final value of the string is 'NaN'
parents=[2 3 1 NaN];
f = parents(size(parents,2));
if f == 'NaN'
check=0
else
check=1
end

Akzeptierte Antwort

per isakson
per isakson am 4 Mai 2019
Bearbeitet: per isakson am 4 Mai 2019
Replace
if f == 'NaN'
by
if isnan( f )

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays 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!

Translated by