Effacer les filtres
Effacer les filtres

Delete numbers that are not in both arrays

1 vue (au cours des 30 derniers jours)
Dylan den Hartog
Dylan den Hartog le 18 Mai 2021
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.

Réponses (1)

Steven Lord
Steven Lord le 18 Mai 2021
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.

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by