Azzera filtri
Azzera filtri

How to find the position of NaN values simultaneously in more arrays?

1 visualizzazione (ultimi 30 giorni)
I have 8 station data vector(5000x1) about temperature, wind and some other variables that have same length. Each of these station arrays have NaN value in some days of the years that I chose for a simulation with another software. I want to know how to find the position (days of the years) in which ALL the stations have NaN values simultaneously. For example:
A = [ 2 5 7 12 Nan Nan 1 5 Nan]
B = [3 Nan 2 1 5 6 Nan 1 Nan]
C = [Nan 1 4 5 6 7 8 9 Nan]
I want to find k = [9], the position in which all stations have NaN values. Thanks a lot VG

Risposte (1)

Stephen23
Stephen23 il 6 Dic 2017
Modificato: Stephen23 il 6 Dic 2017
Just like in every other instance when beginners store data in lots of individual variables, processing that data is much simpler when the data is stored in just ONE array. So the first step is to put those vectors into one matrix, then your task is trivial to achieve:
>> A = [ 2 5 7 12 NaN NaN 1 5 NaN];
>> B = [3 NaN 2 1 5 6 NaN 1 NaN];
>> C = [NaN 1 4 5 6 7 8 9 NaN];
>> M = [A;B;C];
>> find(all(isnan(M),1))
ans = 9

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by