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

1 次查看(过去 30 天)
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

采纳的回答

Awais Saeed
Awais Saeed 2021-8-21
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by