matlab and arduino: serial port connection

Hello, I am trying to hook up matlab to my arduino. I am trying to write a number to the serial port in the arduino IDE and retrieving the same number in the matlab IDE. My arduino code is:

void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); }

void loop() {

if (Serial.available()){ Serial.println(3);

delay(100); // delay in between reads for stability } }

And my matlab code looks like:

%s = serial('COM9'); s = serial ( 'COM9' , 'BaudRate' , 9600, 'terminator' , 'CR' ); %set(s,'BaudRate',4800); fopen(s);

fprintf(s,'*IDN?') fread(s) disp(s) out = fscanf(s); fclose(s) delete(s) clear s

and the matlab output looks like:

10 51 13 10 51 13 10 51 13

How can I change this so only "3" comes out? Thanks!

Bearing in mind that I know nothing about matlab what do these 2 lines set the baud rate to ?

s = serial ( 'COM9' , 'BaudRate' , 9600, 'terminator' , 'CR' );
%set(s,'BaudRate',4800);

The 10 and 13 are the carriage return and line feed that Serial.println() adds. 51 is the ASCII code for ‘3’. Stop printing the integer value. Print the character instead.