matching digits
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have 3 vectors A, B, and C that consist of 4 digits each. is it possible to find the common digits at the beginning of each number. for example: A=1234; B=1248, C =1238; the common two digits are 12. how can I do this matching using matlab?
0 comentarios
Respuesta aceptada
Sean de Wolski
el 30 de Jun. de 2011
A=1234; B=1248; C =1238;
Astr = num2str(A); %you'll need this one 3x so convert it once.
idxstop = find(any(bsxfun(@ne,vertcat(Astr,num2str(B),num2str(C)),Astr),1),1,'first');
common = Astr(1:idxstop-1)
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!