Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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!

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 1 de Abr. de 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,:);

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by