condition for including difference between nan

7 ビュー (過去 30 日間)
Snehalatha
Snehalatha 2015 年 7 月 5 日
編集済み: Guillaume 2015 年 7 月 6 日
Hi Guys, I had the following line for a condition I needed.
if (abs((tempBeforeDelam(i,j,1)-tempBeforeDelam(i,j,2)))< 1 ...
&& abs((tempBeforeDelam(i,j,2)-tempBeforeDelam(i,j,3))) < 1 ...
&& abs((tempBeforeDelam(i,j,3)-tempBeforeDelam(i,j,4))) < 1 ...
&& abs((tempBeforeDelam(i,j,4)-tempBeforeDelam(i,j,5))) < 1 ...
&& abs((tempBeforeDelam(i,j,5)-tempBeforeDelam(i,j,1))) < 1)
and replaced it with
if all( abs( diff([ squeeze(tempBeforeDelam(i,j,:)); tempBeforeDelam(i,j,1) ]) ) < 1)
now I also need to incorporate a condition that says that even if the difference is nan proceed to the next step.
Any help would be appreciated.
Thanks

採用された回答

Guillaume
Guillaume 2015 年 7 月 6 日
編集済み: Guillaume 2015 年 7 月 6 日
somediff = diff([squeeze(tempBeforeDelam(i,j,:)); tempBeforeDelam(i,j,1)]);
if all(abs(somediff) < 1 | isnan(somediff))
%do it
end
The only way of returning true in a comparision expression that contains NaN is to explicitly test it with isnan. NaN is never smaller than, greater than or equal to any number (or another NaN).

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by