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

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?

 Accepted Answer

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 Comments

Thank you sir
and yeah 24x15 may not be a huge one, I have 49 such matrices which i forgot to mention and it's tedious to delete specific elements in every matrix
Thanks anyhow sir
If you have
A=[2 4 ; 5 44];
If you delete the number 5 from your matrix, what will be the result?
Yeah I got you Sir. I should not delete any element from a matrix
May be I should correct my question to -- how can i make specific elements to zero in a matrix
A=[1 2 3 4;
1 8 9 10;
11 12 20 6] ;
idx=ismember(A,[6 10]) % logical indices
A(idx)=0
Thank you sir

Sign in to comment.

More Answers (0)

Asked:

on 26 Jan 2014

Edited:

on 26 Jan 2014

Community Treasure Hunt

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

Start Hunting!