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 件のコメント
Radu Mihail
Radu Mihail 2021 年 8 月 22 日
Thank you very much!
Awais Saeed
Awais Saeed 2021 年 8 月 22 日
You are welcome.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating 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