How to make a NaN vector if there is a single NaN in a column?
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
madhan ravi
on 28 Jul 2020
[m, n] = size(A);
A = nan(m, any(isnan(A(:))) * n)
8 Comments
madhan ravi
on 28 Jul 2020
Sorry I’m not a mind reader:(
ix = nan(m, any(isnan(A(:)))* n);
if isempty(ix)
A = A
else
A = ix
end
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!