Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

What am I doing wrong in my code? Trying to detect if array has NaN.

조회 수: 1 (최근 30일)
Tin Nguyen
Tin Nguyen 2015년 10월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
So this is my code:
x = [ NaN NaN 24 ]
if isnan(x)==1
A=2
else
A=min(x)
end
So I have this code. What I want it to do is to see if there are any NaN's in the vector. If there is an NaN then we make A be 2. If there isn't then A is just the the minimum number of x which is essentially 24.
But when I execute the program it keeps saying A=24 when it should be NaN. Any help would be greaty appreciated.

답변 (1개)

Rick Rosson
Rick Rosson 2015년 10월 14일
if any(isnan(x))

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by