function gotoZ(s,check,currzpos) ZPulseRate = 38400; if(check<200000 && check>-200000) str = sprintf('%06d',abs(round(check))); % abs needed so that no +&- in neg numbers if((check) < 0) newstr = strcat('-',str); else newstr = strcat('+',str); end disp(strcat('moving to position:',newstr)) % end formatting ---------- -------------------------------------------- fprintf(s,'M'); fprintf(s, newstr ); pause(0.035); end end