Find back lost values from an original matrix of derived incomplete column vectors

1 visualización (últimos 30 días)
I have a matrix M and I am extracting a submatrix A of selected column vectors from M , without keeping the values of the third row(substituted by nan). The selection method loses the 3rd row values of columns.
M=[1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2;1,1,1,1,2,2,2,2,4,4,4,1,1,1,2,2,2;1,2,3,4,1,2,3,4,1,2,3,2,3,4,1,2,3;31,16,15,9,10,8,13,6,16,11,4,9,4,10,6,17,15];
A= [1,1,2,2,2;1,2,4,1,2;NaN,NaN,NaN,NaN,NaN;31,13,16,10,17]
Is there a way to retrieve their values of their third row from M specifically?
The result would be R=
1 1 2 2 2
1 2 4 1 2
1 3 1 4 2
31 13 16 10 17
or
R=[1,1,2,2,2;1,2,4,1,2;1,3,1,4,2;31,13,16,10,17]
Thank you

Respuesta aceptada

Awais Saeed
Awais Saeed el 21 de Ag. de 2021
You did not mention how are you picking the columns. I am assuming that you want columns 1 7 9 14 16 from M. If that's the case then
R = M(:,[1 7 9 14 16])
R =
1 1 2 2 2
1 2 4 1 2
1 3 1 4 2
31 13 16 10 17
  7 comentarios

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by