First value in the cycle

1 回表示 (過去 30 日間)
Filip Konecny
Filip Konecny 2018 年 2 月 22 日
編集済み: Birdman 2018 年 2 月 22 日
Hello to all,
I have a matrix with 2 columns. In the first column there is time, in the second there is ID of the time.
So the whole matrix looks for example like this:[1 2 3 4 5 6 7 8 9 10;1 1 1 2 2 2 5 5 5 7]' ([time;ID]')
I need to make a for cycle which goes through the matrix and takes only the first time value for single time ID.
So the result looks like this: [1 4 7 10]
Thank you very much
Best regards

採用された回答

Birdman
Birdman 2018 年 2 月 22 日
編集済み: Birdman 2018 年 2 月 22 日
A=[1 2 3 4 5 6 7 8 9 10;1 1 1 2 2 2 5 5 5 7].';
[~,idx]=unique(A(:,2));
A(idx,1)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by