How to make a NaN vector if there is a single NaN in a column?
1 次查看(过去 30 天)
显示 更早的评论
Say you have a vector
A= [ 2 4 6 8 NaN 10 12 14]
How do you make a NaN vector if and only if there is a NaN in one of the columnns:
A = [NaN NaN NaN NaN NaN... ]
0 个评论
采纳的回答
madhan ravi
2020-7-28
[m, n] = size(A);
A = nan(m, any(isnan(A(:))) * n)
8 个评论
madhan ravi
2020-7-28
Sorry I’m not a mind reader:(
ix = nan(m, any(isnan(A(:)))* n);
if isempty(ix)
A = A
else
A = ix
end
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!