Matlab updates figure too slowly
1 view (last 30 days)
Show older comments
I have a timer function set to a 0.02s Timer period that reads in voltage from an arduino via a serial port 's' and then sets the position of a rectangle according to the measured voltage using the handle 'bb' that I passed to the callback function. My problem is that Matlab updates the position of the rectangle with a roughly 5s delay and then stalls although each iteration takes less than 0.001s to execute. If I use the slower readVoltage command, then I do not have that problem. Is the 'set' command too slow to keep up with the 50 Hz?
The code is the following:
function disp_function (obj,~,bb,s)
n=get(obj,'TasksExecuted');
data=fscanf(s,'%f'); %get the voltage from
bar_pos = ((data - 0.7) ) *2 ;
bar_pos = round(bar_pos*100)/100;
% UpdatePlot(bar_pos);
set(bb,'Position', [0.2,bar_pos,0.6,0.1]) %bar handle
drawnow
% newdat=tmp_data;
end
2 Comments
Answers (0)
See Also
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!