フィルターのクリア

Delete numbers that are not in both arrays

1 回表示 (過去 30 日間)
Dylan den Hartog
Dylan den Hartog 2021 年 5 月 18 日
回答済み: Steven Lord 2021 年 5 月 18 日
I have four arrays. I want to delete all the numbers that are not in all of the four arrays.
So for example:
A1 = [1 2 3 4 5]
A2 = [2 3 4 6 7]
A3 = [1 2 3 4 6]
A4 = [2 3 4 5 6]
I want to do the following automatically:
A1([1 5]) = [] --> A1 = [2 3 4]
A2([4 5]) = [] --> A2 = [2 3 4]
A3([1 5]) = [] --> A3 = [2 3 4]
A4([4 5]) = [] --> A4 = [2 3 4]
So I want to find the indices to delete the columns that I don't want.

回答 (1 件)

Steven Lord
Steven Lord 2021 年 5 月 18 日
Use the intersect function a couple times. That will be easier if you define an array or a cell array of data rather than using numbered variable names.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by