Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
how to get the same elements from many different vectors and each index for each vectors?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
for example, now I have three vectors as below:
v1=['a','b','c','d','e','f']; v2=['a','c','d','f','g']; v3=['c','d','e','j'];
Now I want to get the same elements ['c','d'] and index1=[3,4],index2=[2,3],index3=[1,2];
Is there some good function for this?
0 comentarios
Respuestas (1)
KSSV
el 8 de Feb. de 2017
doc intersect
clc; clear all ;
v1=[{'a'},{'b'},{'c'},{'d'},{'e'},{'f'}];
v2=[{'a'},{'c'},{'d'},{'f'},{'g'}];
v3=[{'c'},{'d'},{'e'},{'j'}];
[a1,b1,c1] = intersect(v1,v2) ;
[a2,idx2,idx3] = intersect(a1,v3) ;
[common,idx1,c3] = intersect(v1,a2) ;
common
idx1
idx2
idx3
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!