matlab - How to remove specific elements of a matrix? -
I'm having a bad day at work. I have a very simple question.
I have 2x100 metrics, such as
[1 2 3 4 5 6 -2 -3 .... 2 4 5 3 2 -4 3 3 ..] To examine the first line of the matrix and delete all the numbers above 2 and remove the associated entry line 2. So for example, if there is only 1 element in comparison to the upper case then our matrix will become 2x99 matrix.
You should use logical sequencing:
idxToKeep = yourMat (1, :) & lt; = 2; NewMat = yourMat (:, idxToKeep); Or if you do not want to create a new matrix:
yourMat = yourMat (:, idxToKeep); or all in one-liner:
yourMat = yourMat (:, your Mate (1, :) & lt; = 2);
Comments
Post a Comment