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

1 view (last 30 days)
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

Accepted Answer

per isakson
per isakson on 4 May 2019
Edited: per isakson on 4 May 2019
Replace
if f == 'NaN'
by
if isnan( f )

More Answers (0)

Categories

Find more on Cell Arrays 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!