The following may be helpful:
Note: a space acts as a delimiter for commands sent to the motor
function openmoveclose(x)
%open the serial port COM1
%apply the displacement x (in steps)
%close the port
% choose the serial port COM1
s = serial('COM1');
% set all the properties of the port
s.BaudRate = 9600;
s.DataBits = 8;
s.Terminator = 'LF/CR';
s.RequestToSend = 'off';
s.FlowControl = 'software';
s.DataTerminalReady = 'off';
s.parity = 'none';
%open the port
fopen(s);
%apply displacement
%allow 5ms second for initialization => prevent 'fuzzy' dismissal of the command
%clear the board memory
%remove hardware limits, set velocity and acceleration
preamble = ['EIGN(2) EIGN(3) ZS a=0 AT=9000 VT=283032 END'];
command = ['WAIT=5' ' ' 'PT=' int2str(sign(x)*round(abs(x))) ' ' 'G'];
fprintf(s,preamble);
fprintf(s,command);
%close the port
fclose(s);
delete(s)
clear s;
end