Borrar filtros
Borrar filtros

How extract a submatrix out of a main matrix?

1 visualización (últimos 30 días)
Naruto
Naruto el 8 de Nov. de 2020
Comentada: Ameer Hamza el 9 de Nov. de 2020
I have a matrix A (50x2) and I want to extract a certain number of row observations that statisfies the condition where I output the rows that include '1' in column 2 along with another column that would state 'yes'. How can I do that?
The first column are the ID numbers and the second column would be a '1' for yes and a '0' for no.
I understand that a for loop would be applicable here but I have tried out a couple which didnt work out in adding it an extra column displayed.
thanks.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 8 de Nov. de 2020
Easy peasy
M_new = M(M(:,2)==1,:); % M is your n*2 matrix
  2 comentarios
Naruto
Naruto el 8 de Nov. de 2020
Nice! Thanks for the link as well.
Ameer Hamza
Ameer Hamza el 9 de Nov. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by