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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Awais Saeed
Awais Saeed il 21 Ago 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 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by