Substitute matrix values without mchange

1 回表示 (過去 30 日間)
Brian
Brian 2014 年 12 月 9 日
コメント済み: Brian 2014 年 12 月 11 日
I am using some code to substitute values without the symbolic toolbox. The code follows.
  1. 1: B=A(A>2)
  2. 2: T=zeros(size(A)
  3. 3: mask=A>2
  4. 4: T(mask)=A(mask)
A represents an absolute value matrix. The lines of code remove any value less than 2. We want to modify code so that it instead removes anything greater than 2 AND anything less than -2.

採用された回答

Guillaume
Guillaume 2014 年 12 月 9 日
Not sure what this has got to do with the symbolic toolbox. It's basic matlab.
Anything greater than 2 and anything less than 2 is anything not equal to 2, so:
T = A;
T(T~= 2) = 0;
  2 件のコメント
Brian
Brian 2014 年 12 月 11 日
I wanted to change the range -2<A<2 to 0 Not just 2.
Brian
Brian 2014 年 12 月 11 日
Nevermind. I figured it out
T=A;
T(abs(T)<2)=0;

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by