Matlab updates figure too slowly
古いコメントを表示
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 件のコメント
Use
% if true
% code
% end
drawnow limitrate
To update figure faster
Friedrich Krohn
2020 年 10 月 2 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB Support Package for Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!