Matlab reading Xbee always returns 49?

Using really simple matlab code:

s = serial('COM3');
fopen(s);
A=fread(s, 100);

I'm always reading the value of 49 in.

My current arduino code is just printing "1" to the serial repeatedly. I have tried having my arduino print 1-100 on the serial port instead, but then my matlab returns random values between 48-57. Terminal shows the proper stream of values in.

Does anyone know what I'm doing wrong?

ASCII character 49 is '1'. http://www.asciitable.com/

Ah, okay, I'm assuming then that the xbee reads in chars all the time? Is there a way in matlab or arduino to make it so that I can read ints in matlab?

If you are using Serial.print(), then you are asking the Arduino to convert whatever you are printing into a human readable format. Try using Serial.write() instead, and see what that does.

Ah, the works perfectly, thank you :slight_smile: