MATLAB Answers

using function to remove elements from a large matrix

1 view (last 30 days)
Malik Khan
Malik Khan on 25 Dec 2019
Edited: Malik Khan on 3 Jan 2020
I need to code for a matrix in which the rows are removed given thier value in a certain column is not of desire to me. eg, I want to keep the numbers 1 2 3 and 11 and 12 but not 4 5 6 or 13 14 etc.

  3 Comments

Malik Khan
Malik Khan on 25 Dec 2019
I have not attempted this yet because I have no idea where to start

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 25 Dec 2019
Edited: the cyclist on 25 Dec 2019
idxToKeep = ismember(M(:,2),[1,2,3,11,12]);
M = M(idxToKeep,:);

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by