Removing low values from a matrix

Hi
I have a small problem, I have a 134x10 matrix, which has some noise elemetns. I would like to remove them.
As in the picture below, all elements less than 0.0108 are noise. I am attaching the file
I tried this code
ModeShapes(ModeShapes < 0.01) = [];
but this doesnot works as I want.
Does anybody knows how it can be done

5 件のコメント

Jan
Jan 2021 年 2 月 6 日
You explain, that the shown code does not work as you want, but you forgot to mention, what you want instead. What do you want to happen?
Chris Dan
Chris Dan 2021 年 2 月 6 日
Hi,
This is what I get, the matrix changes dimensions
Jan
Jan 2021 年 2 月 6 日
Of course the matrix changes its dimensions, when you delete elements. This belongs to the definition of matrices: All rows and columns need to have the same number of elements, respectivly. See an example:
A = [1, 2; 3, 4]
What do you expect, if you "remove" the 1st element? The output cannot be a 2x2 matrix, if there are 3 elements only.
Yo you can set the value of an element to 0 or to NaN, but there is no way to "remove" it. You can remove rows and/or columns, but not elements.
Chris Dan
Chris Dan 2021 年 2 月 6 日
Okay,
and if I want to remove the rows that have neglible values, how to do that
Jan
Jan 2021 年 2 月 7 日
Exactly as @KALYAN ACHARJYA has posted already, or slightly faster:
X(any(X < 0.0108, 1), :) = [];

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

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 6 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 6 日

1 投票

Remove menas, you have to replace by other certain values, so that it can be easily distinguishable.
mat(mat<0.0108)=0
or
mat(mat<0.0108)=NaN
More: You cann't completely delete the certain matrix elements (replace option), but you can either delete the certain rows or column easily complete.

4 件のコメント

Chris Dan
Chris Dan 2021 年 2 月 6 日
Hi,
yes, I want to delete those rows which are less than 0.01
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 6 日
[r,~]=find(mat<0.0108);
mat(r,:)=[]
The code will delete the all rows, if it has any one or more element<0.0108. The resultant matrix will have reduced number of rows after deletion (if any matrix element have less than 0.0108).
Chris Dan
Chris Dan 2021 年 2 月 6 日
it is not working, I am getting a 0 x 10 matrix.
I am attaching the file
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 6 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 7 日
Yes, because there are atleast one value (which is less than 0.0108) in each row of ModeShapes matrix, hence it shows the all rows deletion.
Rethink on "yes, I want to delete those rows which are less than 0.01"?

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

製品

リリース

R2019a

質問済み:

2021 年 2 月 6 日

コメント済み:

Jan
2021 年 2 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by