フィルターのクリア

How to check each element of a vector with each elements of another vector if dimension of both matrix are not equal

1 回表示 (過去 30 日間)
I have two vector
A=[1;4;7] and B=[4;6;1;3;2;8;0]
Now I want to check whether each elements of A are present or not in B. If present then how to display or store thats elements.
i.e C=[1;4]
Please help me
for i=1:size(A,1)
for j=1:size(B,1)
if(A(i)==B(j))
C(i)=A(i)
end
end
end
This code is not working.

採用された回答

Stephen23
Stephen23 2019 年 5 月 3 日
編集済み: Stephen23 2019 年 5 月 3 日
>> C = intersect(A,B)
C =
1
4

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by