Matlab code synchronizing and visualization