Matlab and PICAXE comms

Anyone out there who knows how to make Matlab work with serial communications?

I'm in the early stages of writing a matlab program to do inverse kinematics for a leggy kinda robot, and I want to get it to send the numbers to a picaxe via rs232 - seems fairly straightforward?

My test program is behaving wierdly

*code*

 

Picaxe = serial('COM4');

set(Picaxe,'BaudRate', 9600, 'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none'); 

fopen(Picaxe);

fprintf(Picaxe,'1234');

Picaxe.ValuesSent

B = fread(Picaxe)

stopasync(Picaxe)

fclose(Picaxe);

delete(Picaxe)

clear Picaxe

*/code*

The Picaxe code goes like this

 

main:

serrxd w1

pause 50

sertxd(w1)

goto main

 

The idea is that the picaxe gets the recieved data and sends it straight out again, but when the string is more than 1 character, as it is here, it just returns the first value, no sign of the others. Also I can't get it to terminate once Matlab has recieved the data, it just sits there until it times out and gets upset.

Feel free to ask if I haven't been clear, any and all help gratefully recieved...

Mike

 

Not familair with matlab

For knowing when it is end of string I send and test for a zero. That must be possible to program somehow in matlab.