필터 지우기
필터 지우기

obtain a sequence from a matrix

조회 수: 1 (최근 30일)
Elysi Cochin
Elysi Cochin 2016년 5월 12일
댓글: Elysi Cochin 2016년 5월 13일
i have a matrix as shown below
from the above matrix "M" of size 11 x 11, i need to get "output" of size 1 x 11... i need to get a sequence written in red color below the image...
start from i = 1; M(i,1); save output = M(i,1); go to the i = 2; M(i,1); eg: 4 go to 1st row of 4th col; M(1,4) - save that to output = [1 4]; go to M(2,4) - go to that column - i.e. M(1,2) - save that to output = [1 4 2] repeat till all numbers from 1 to 11 are obtained without repetion..
if repeated go to M(j,col) where j is the non-repeated row value of that particular column....
please can someone help me how to goto the column i need ....
  댓글 수: 1
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2016년 5월 12일
initially you practise with input having 1 column, after understanding proceed for two columns, after understanding proceed for three columns.. then proceed for this image which you shared. you will get it.

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

채택된 답변

Guillaume
Guillaume 2016년 5월 12일
편집: Guillaume 2016년 5월 12일
Please post matlab code in addition to a picture so we don't have to type your matrix ourselves.
M = [1 2 3 4 5 6 7 8 9 10 11;
4 5 6 5 2 5 4 5 6 1 3;
10 4 11 2 4 2 10 4 11 7 9;
2 6 2 8 6 8 8 6 8 4 6]; %demo data shortened as I'm not going to type it all
v = M(1, 1); %starting point
currentcolumn = 1;
while currentcolumn
currentcolumn = M(find(~ismember(M(:, currentcolumn), v), 1), currentcolumn); %find the 1st row of M(:, currentcolumn) that is not a member of V. Use the value at that row as the new currentcolumn
v = [v, currentcolumn];
end
  댓글 수: 1
Elysi Cochin
Elysi Cochin 2016년 5월 13일
thank you so much sir...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by