Ignoring [NaN; NaN]

3 ビュー (過去 30 日間)
Fiona Rae
Fiona Rae 2017 年 7 月 8 日
コメント済み: Fiona Rae 2017 年 7 月 8 日
Hey everyone! This might seem silly but I don't see a way around this. I have two vectors, A and B
A = [Ax; Ay];
B = [Bx; By];
By solving certain equations, I get values for A and B. Below are some random examples.
Case 1:
A = [2; 5]
B = [3; 6]
Case 2:
A = [NaN; NaN]
B = [2; 6]
Case 3:
A = [5; 8]
B = [NaN; NaN]
It is set up in such a way that both A and B can't be [NaN; NaN] at once. If Case 2 happens, I want the program to ignore A and output B. If Case 3 happens, I want the program to ignore B and output A. If Case 1 happens, I proceed with using A and B for further calculations. Advice?

採用された回答

Guillaume
Guillaume 2017 年 7 月 8 日
if all(isnan(A))
A = B;
elseif all(isnan(B))
B = A;
end
%proceed with A and B
  1 件のコメント
Fiona Rae
Fiona Rae 2017 年 7 月 8 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by