フィルターのクリア

Compare vectors and save the values

1 回表示 (過去 30 日間)
pamela sulis
pamela sulis 2016 年 4 月 6 日
回答済み: Adam 2016 年 4 月 6 日
Hi! I have
T=[1 1;1 2;1 3;1 4;256 2;259 2;263 2;268 2;315 2;330 3;335 3;336 2;337 2;338 2;339 2;340 2;345 2;345 3;349 2;354 2];
S= [1 345 360]
I want to compare the values in S (1, 345, 360) with the values of first column of T: if there is a corrispondence, I want to save the row.
I want output C=[1 1;1 2;1 3;1 4;345 2;345 3]. Can you help me?

採用された回答

Adam
Adam 2016 年 4 月 6 日
idx = ismember( T(:,1), S );
C = T( idx, : );

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by