how to turn elements in matrix to 0?

4 ビュー (過去 30 日間)
Kobi
Kobi 2014 年 10 月 8 日
編集済み: José-Luis 2014 年 10 月 8 日
i have this matrix:
arround this shape the elements are close to zero (in a small values for example: xe-20-xe-10) is there a simple way to take the elements only around this shape and change them into zero?
  1 件のコメント
Kobi
Kobi 2014 年 10 月 8 日
i tried to do this in this way but i don't understand what is wrong
[col,row]=find(abs(diag(T))<0.2); T(row,col)=0;
i'm expecting to zero only a square around the shape in this way

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

回答 (2 件)

Chad Greene
Chad Greene 2014 年 10 月 8 日
If you'd like to change all values in T that are less than some threshold (we'll call the threshold thresh), all you need is
T(T<thresh)=0;
  2 件のコメント
Kobi
Kobi 2014 年 10 月 8 日
not for all the values only for a square of zeros i managed to do this in a way that i don't really like i create a threshold for the diognal values of the matrix and take 10% from the scale
treshold=(max(max(abs(diag(T))))-min(min(abs(diag(T)))))*0.1; ind=find(abs(diag(T))<treshold);
but i don't like this because i need to set the threshold manually
any suggestions?
José-Luis
José-Luis 2014 年 10 月 8 日
編集済み: José-Luis 2014 年 10 月 8 日
Well, a threshold is subjective, even when applying complex statistical methods. You are going to have to select something. Even if you use a function, the choice is subjective.
I guess what I am trying to ask is how do you want to set that limit?

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


Chad Greene
Chad Greene 2014 年 10 月 8 日
If it's a matter of numerical noise eps may help.

カテゴリ

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