How to find the position of NaN values simultaneously in more arrays?
1 回表示 (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
Stephen23
2017 年 12 月 6 日
編集済み: Stephen23
2017 年 12 月 6 日
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で NaNs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!