Effacer les filtres
Effacer les filtres

Match elements of column array to first column of a matrix then append row of matrix to array

1 vue (au cours des 30 derniers jours)
Hello - I have a column of sets of repeated numbers:
C = [219; 219; 219; 6401; 6401; 6401; 6401; 7501; 7501];
The matrix is like this:
B = [206 3 4 5; 219 4 5 7; 5005 7 5 2; 6401 2 1 8; 7002 1 3 7; 7501 9 4 2};
I want to match a value in the first column of B to the same value in the column A, and then append the remaining rows of B to A.
C = 219 4 5 7
219 4 5 7
219 4 5 7
6401 2 1 8
6401 2 1 8
6401 2 1 8
6401 2 1 8
7501 9 4 2
7501 9 4 2
Thanks!

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 1 Avr 2014
A = [219
219
219
6401
6401
6401
6401
7501
7501];
B = [206 3 4 5
219 4 5 7
5005 7 5 2
6401 2 1 8
7002 1 3 7
7501 9 4 2];
[l,ii] = ismember(A,B(:,1));
C = B(ii,:);

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by