How Can I delete specific elements in a matrix and transfer them to other

1 回表示 (過去 30 日間)
Divya
Divya 2014 年 1 月 26 日
編集済み: Divya 2014 年 1 月 26 日
How Can I delete specific elements in a matrix(rectangle matrix) and transfer them to other variable?
For example:
A=[1 2 3 4;
1 8 9 10;
11 12 20 6] ;
Suppose I want to delete 10 and 6, with out specifying element wise is there any way that i can delete the elements? Since my matrix is huge(24x15 elements) I can't specify element wise. I can only specify which row and which column.
Is there any technique that works efficiently?

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 26 日
編集済み: Azzi Abdelmalek 2014 年 1 月 26 日
A=[1 2 3 4;
1 8 9 10;
11 12 20 6] ;
You can't delete any element from your matrix. You can delete an entire column or an entire row.
You can find the position of your number 6 and 10 in your matrix
[ii,jj]=find(ismember(A,[6 10]))
a 24x15 array is not a huge matrix!
  5 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 26 日
編集済み: Azzi Abdelmalek 2014 年 1 月 26 日
A=[1 2 3 4;
1 8 9 10;
11 12 20 6] ;
idx=ismember(A,[6 10]) % logical indices
A(idx)=0
Divya
Divya 2014 年 1 月 26 日
編集済み: Divya 2014 年 1 月 26 日
Thank you sir

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by