How to make a for loop run consecutively?
Ältere Kommentare anzeigen
I have column vectors imported numerically that sometimes have NaN. This data corresponds to the position of an animal in a pool, where the NaN values at the beginning are not significant and need to be discarded, whereas there could be NaN values elsewhere (ie. after the first numerical value) that need to be addressed in a different manner. I'm not sure if this is the best way to approach this, but I envision using a while and for loop to evaluate the first row of the TF, if 1 delete row 1 in the associated column vectors, and then evaluate the new row 1 until row 1 is no longer a 1/NaN.
TF = isnan(X);
for m = 1
if TF(m) == 1
X(m) = [];
Y(m) = [];
Z(m) = [];
end
end
This is what I have so far. The only method I have found that works as intended is to copy and paste this for loop consecutively hundreds of times. However, I feel as if there must be a better way. Thanks for your help.
Akzeptierte Antwort
Weitere Antworten (1)
KSSV
am 21 Feb. 2018
YOu can remove the NaN's directly using:
TF(isnan(TF)) = [] ;
k = [NaN 2 3 NaN 5]
k(isnan(k)) = [] ;
1 Kommentar
Rameen Forghani
am 21 Feb. 2018
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!