フィルターのクリア

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