How to change values meeting certain criteria to NaN... in certain columns only

1 次查看(过去 30 天)
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)?

采纳的回答

madhan ravi
madhan ravi 2019-2-28
编辑:madhan ravi 2019-2-28
B=A(:,2:2:end);
idx=B>100;
B(idx)=NaN;
A(:,2:2:end)=B

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by