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