I had the same problem and managed to solve it using the following generic Matlab Code to read from the Serial Port:
%Basic Comm
s = serial('COM5');
set(s,'BaudRate',9600);
set(s,'DataBits',8);
set(s,'StopBits',1);
fopen(s);
fprintf(s,'*IDN?')
out = fscanf(s);
fclose(s)
delete(s)
clear s
On the other hand I did some code to read signals from the ADXL30 with the arduino.
I programmed the arduino so that it would send a serial stream as the following
X<accX> [space] Y <accY> [space] Z [accZ] [CR]
where <accX> is the value of the A/D comming from the accelerometer.
I enclose the MATLAB side,
%Graph Accelerometer Data
s = serial('COM5');
set(s,'BaudRate',9600);
set(s,'DataBits',8);
set(s,'StopBits',1);
fopen(s);
out ='a'
figure
hold on
xacc =[];
yacc =[];
zacc =[];
for i = 1 : 5000
out = fscanf(s);
if(sum(size(out))>0)
out2 = reshape(out(1:(round(size(out,2)/5)-1)*5),[5 (round(size(out,2)/5)-1)]);
out2 = out2';
out2 = str2num(out2(1:end,2:end));
if out(1) == sprintf('X')
xacc = [xacc out2(1:3:end)'];
plot(xacc);
yacc = [yacc out2(2:3:end)'];
plot(yacc,'r');
zacc = [zacc out2(3:3:end)'];
plot(zacc,'g');
end
drawnow
end
end
fclose(s)
delete(s)
clear s
This code only reads the signals from the serial port, stores them in different variables (depending on the axis) and plots them.
The main problem with Matlab ,though, is that is not fast enough to process all the datam, you'll see (if you try the code) that the graphs are drawn pretty slow (I got a celeron but I do not think that's the problem.
If you are interested in the Arduino code for that, let me know.
Dolphin