How to find repeated array in a matrix

Hello everyone,
Suppose matrix a is like:
a=[1;2;2;3;3;4;5;6;6;7;7;7;8];
and matrix b:
b=[2;7;1;3;2];
Then, I want matrix c to be like:
c = [2;3;10,11,12,1,4,5,2,3]
Matrix c is found an array of matrix b in matrix a, If it finds more than one, then it will write both or more row numbers in the matrix c

 Réponse acceptée

Sara
Sara le 9 Juil 2014
d = [];
for i = 1:numel(b)
d = [d;find(a==b(i))];
end

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 9 Juil 2014
Modifié(e) : Azzi Abdelmalek le 9 Juil 2014

0 votes

You can use ismember and find function

Catégories

En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by