NaN selective removal from a matrix
1 回表示 (過去 30 日間)
古いコメントを表示
I have a matrix like this: a=[NaN NaN NaN NaN;NaN NaN NaN NaN;2 3 NaN 4;9 4 NaN 4;3 9 NaN 3];
and i want to remove all the rows that contains only NaN's to: b=[2 3 NaN 4;9 4 NaN 4;3 9 NaN 3];
please help me,
Ziv.
0 件のコメント
採用された回答
Jos (10584)
2014 年 7 月 9 日
tf1 = isnan(a)
tf2 = all(a,2)
tf3 = ~tf2
b = a(tf3,:)
b2 = a(~all(isnan(a),2),:) % in one giant leap
その他の回答 (1 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!