data comparision in matlab

1 回表示 (過去 30 日間)
Lalit Patil
Lalit Patil 2012 年 11 月 6 日
After using image processing I have a [r c] = [1 7;2 8;3 9;4 10;5 11;6 12]; and [R C] = [2 8;1 6;4 9;3 9;6 12;8 1;0 15];
The answer should be [A B] = [2 8;3 9;6 12] I want to find all that [R C] which are in [r c]...

採用された回答

Wayne King
Wayne King 2012 年 11 月 6 日
編集済み: Wayne King 2012 年 11 月 6 日
A = [1 7;2 8;3 9;4 10;5 11;6 12];
B = [2 8;1 6;4 9;3 9;6 12;8 1;0 15];
lia = ismember(A,B,'rows');
Anew = A(lia>0,:);
Anew contains the rows that are common.

その他の回答 (1 件)

Jan
Jan 2012 年 11 月 6 日
This is a bold question.
1. This is no valid Matlab syntax:
[r c] = [1 7;2 8;3 9;4 10;5 11;6 12];
[R C] = [2 8;1 6;4 9;3 9;6 12;8 1;0 15];
On the left hand you have two variables, on the right hand only one array in each line. It is impossible to guess, what this should mean.
2. The information "after using image processing" does not help to understand the problem. It increases the confusion level only.
3. "The answer should be [A B] = [2 8;3 9;6 12]" - beside the invalid syntax, which does not allow us to find out, what you want to achieve, you did not explain, what you have tried so far. A forum is not a "do it 4 me" machine.
4. With a lot of guessing, I assume, that ismember(R, r, 'rows') will solve your question.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by