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

3 ビュー (過去 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
  1 件のコメント
Corymbiamaculata
Corymbiamaculata 2019 年 2 月 28 日
Thanks! I should have thought of that.
PS The avatars :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by