フィルターのクリア

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 Center および File ExchangeImage Data Workflows についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by