I need to extract a row that coincides with a number in the first column.

조회 수: 1 (최근 30일)
Jeff
Jeff 2016년 5월 31일
댓글: Jeff 2016년 6월 1일
Based on a number in column a, need to fill the rest of the row with the coinciding information.
  댓글 수: 3
Image Analyst
Image Analyst 2016년 5월 31일
Actually there is not even a question here. Just an announcement. If you decide to ask a question, please read this first.
Jeff
Jeff 2016년 6월 1일
Sorry guys, though I can usually figure this stuff out, I am not up on all the proper language to use. I am a simpleton with a skill above what it should be, I will try this and get back with you.

댓글을 달려면 로그인하십시오.

답변 (1개)

Roger Stafford
Roger Stafford 2016년 5월 31일
I agree with Cyclist’s comment as to the lack of clarity in your request, but I will take a very wild guess as to what you are asking. You have an array in which the values in the first column can be regarded as row indices, and that means they must be positive integers not exceeding the number of rows. You wish to replace columns (other than the first column?) by the elements that are currently in the row corresponding to that first column value if it is regarded as a row index.
Let A be your array.
A = A(A(:,1),:);
Or perhaps if you don’t want the first column values to change, you mean this:
A(:,2:end) = A(A(:,1),2:end);

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by