comparing two matrix of different size

1 回表示 (過去 30 日間)
Arne1234
Arne1234 2017 年 11 月 7 日
コメント済み: Arne1234 2017 年 11 月 7 日
Hi,
I have two Matrices like: A= 13253 x 1 double and B= 61022 x 1 double.
I want to compare the value of matrix B with A. And my result i want to put in C wit the same size of matrix A (13253 x 1).
So when any nummer in matrix B is also in matrix A, i want to have a '1' on that location in matrix C.
Example: A = [ 0 1 2 3 4 5 ] B = [ 13 8 9 0 3 6 12 5 1 10 11 ]
C = [ 1 1 0 1 0 1]
How can I do that? Do i use ' find() '?
Thanks in Advance.

採用された回答

KSSV
KSSV 2017 年 11 月 7 日
編集済み: KSSV 2017 年 11 月 7 日
Read about ismember
A = [ 0 1 2 3 4 5 ] ;
B = [ 13 8 9 0 3 6 12 5 1 10 11 ] ;
% C = [ 1 1 0 1 0 1]
C = ismember(A,B)
  1 件のコメント
Arne1234
Arne1234 2017 年 11 月 7 日
Thanks!

サインインしてコメントする。

その他の回答 (1 件)

KL
KL 2017 年 11 月 7 日
ismember(A,B)
  1 件のコメント
Arne1234
Arne1234 2017 年 11 月 7 日
Thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by