How can I delete numbers in a matrix that is not equal to numbers in another matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
I know the title may be a little confusing.Say I have A =[1 2 2 3 3 4 4 ] and B = [2 3 4], how can I make A 'realize ' that there is a number in it different from B and delete it? Is there any simple way to do that? I want to avoid loops......Thanks!
0 件のコメント
回答 (1 件)
Lessmann
2015 年 11 月 5 日
Hi,
you can use logical indexing with the 'ismember' function:
A= A(ismember(A,B))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!