How to change values meeting certain criteria to NaN... in certain columns only
4 views (last 30 days)
Show older comments
Corymbiamaculata
on 28 Feb 2019
Commented: Corymbiamaculata
on 28 Feb 2019
I have a large matrix with 96 columns and thousands of rows. I would like to find all values values larger than 100 in even-numbered columns (2, 4, 6...) and replace them with NaN.
I know of:
A(A(:,2)>100,2) = NaN;
How can I make it work with multiple columns (:,2:2:end)?
0 Comments
Accepted Answer
madhan ravi
on 28 Feb 2019
Edited: madhan ravi
on 28 Feb 2019
B=A(:,2:2:end);
idx=B>100;
B(idx)=NaN;
A(:,2:2:end)=B
More Answers (0)
See Also
Categories
Find more on NaNs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!