MATLAB Answers

M@lik Ali

Extracting new matrix from existing matrix

Asked by M@lik Ali
on 3 Sep 2012

Hi all

I have matrix with 999*10

actually i have 10 feature of 999 images. now what i want is i want to extract features of some images in new matrix like i need the new matrix of 4,5,6 and 7 images among 999 images. my new matrix should be of size 4*10.

How can i do this please help me.

  1 Comment

It's unclear to me.


No products are associated with this question.

2 Answers

Answer by Image Analyst
on 3 Sep 2012
Edited by Image Analyst
on 3 Sep 2012
 Accepted answer

Try this:

rowsToKeep = [4, 5, 6, 7, 42];
extractedMatrix = originalMatrix(rowsToKeep , :);

Note: the rows to keep do not need to be consecutive. If they were though, you could do it in one line like this:

extractedMatrix = originalMatrix(4:7, :);


Answer by M@lik Ali
on 3 Sep 2012

Thanks it working


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!