IF.....OR with conditions
Mostra commenti meno recenti
Hi!
I have two vectors, call them A and B, and I want an IF loop to write them in a table if they aren't NaNs.
The expression
if isnan(A)
works, but I want to evaluate both vectors. I tried:
if isnan(A) || is nan(B)
and this doesn't work:
Error using | Matrix dimensions must agree
True, they are not the same size but I don't want to compare them! I just want to evaluate both. if I do 2 ifs, it won't work for my project.
Thank you for your help!
Risposta accettata
Più risposte (1)
Thomas Koelen
il 9 Apr 2015
N=NaN(1,3);
N2=NaN(1,4);
if any(isnan(N)) || any(isnan(N2))
end
any will give you a single logical value!
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!