フィルターのクリア

Small matrix values

13 ビュー (過去 30 日間)
Nikolaos
Nikolaos 2011 年 12 月 5 日
回答済み: narendra kumar 2016 年 7 月 23 日
Hallo,
for a given matrix is there an efficient way in matlab to make its small values (e.g. smaller than 0.001) set as zero?
Thanks in advance

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 12 月 5 日
e.g. A - your matrix
A(abs(A)<1e-3)=0
  2 件のコメント
Nikolaos
Nikolaos 2011 年 12 月 5 日
thanx a lot, but what if i want to set zero to the matrix values which have either real part <0.001 and imaginary value <0.001
Walter Roberson
Walter Roberson 2011 年 12 月 5 日
A(abs(real(A))<0.001 | abs(imag(A))<0.001) = 0;
Note though that if you had a number such as 12345+0i then this would be set to 0, because you asked for the value to be set to 0 if *either* the real or imaginary part were small. You might wish to change the | to &

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

その他の回答 (1 件)

narendra  kumar
narendra kumar 2016 年 7 月 23 日
A(abs(real(A))<0.001

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by