So, I am using Matlab Mobile to try and make a rolling plot that updates with the z axis of the accelerometer data from my android phone. I connected correctly and have written this code which works:
%connect to phone and get accel data
clear mm = mobiledev;m.AccelerationSensorEnabled = 1;m.Logging = 1;%initialize data for rolling plot
data = zeros(1,200);ticwhile (toc < 30)%run for 30 secs
%read from accel
a = m.Acceleration; %conditional prevents it from indexing an empty array the first couple
%of times
if(exist('a','var')&&~isempty(a)) %get new z coordinate
newPoint = a(3); %concatenate and pop oldest point off
data = [data(2:length(data)) newPoint]; %draw plot with set axes
plot(data); axis([0 200 -15 15]); drawnow end end
My problem is that the resulting rolling plot doesn't resample the data quick enough for what I want. It results in a stepfunction that updates every second or so. Is there anyway to make it resample faster or is this simply due to the nature of the matlab mobile wifi connection? If so, is it possible to connect with bluetooth or some other method such that matlab gets updated points more frequently?
Best Answer