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)
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!