How to remove NaN from 2 column vectors?
1 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I have 2 column vectors with 12 values each:
X = [2 4 8 NaN 13 NaN 3 6 NaN 38 40 11]
Y = [NaN NaN 2 NaN 10 67 1 NaN NaN 19 26 NaN]
I want to remove NaN from these vectors such that if first NaN from Y is removed value '2' from X also gets removed. Similarly if any NaN from X is removed respective value from Y also gets removed.
Kindly suggest me how to do this. Thank you
0 个评论
采纳的回答
Scott MacKenzie
2021-7-12
编辑:Scott MacKenzie
2021-7-12
X = [2 4 8 NaN 13 NaN 3 6 NaN 38 40 11];
Y = [NaN NaN 2 NaN 10 67 1 NaN NaN 19 26 NaN];
nanLogical = isnan(X) | isnan(Y);
X(nanLogical) = []
Y(nanLogical) = []
更多回答(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!