two matrix in one, condition...matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I got 2 matrix
A=[1 10 3;1 12 4;2 5 10;2 6 14;5 14 13]; B=[1 1 4;1 10 16;1 12 15;1 18 1;2 5 11;2 6 7;2 8 16];
Output should be [1 10 3 16;1 12 4 15; 2 5 10 11;2 6 14 7] ;
Matrixes A and B must have same elements in column 1 and 2 (somekind intersect), and in 3rd and 4th column must write value that belong each row that are same in column 1 and 2.
Thanks in advance, Nejc
0 comentarios
Respuesta aceptada
Cedric
el 9 de Abr. de 2013
>> [C,ia,ib] = intersect(A(:,1:2),B(:,1:2),'rows') ;
>> result = [C, A(ia,3), B(ib,3)]
result =
1 10 3 16
1 12 4 15
2 5 10 11
2 6 14 7
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Install Products en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!