필터 지우기
필터 지우기

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