Plotting to multiple GUI axes simultaneously using a for loop
이전 댓글 표시
Hi,
I am trying to build a GUI to plot real-time data from an Arduino. The code needs to read the values in from four analog pins and plots the data on each of the 4 axes in the Matlab GUI, respectively. The code I have at the moment works, however it is rather slow. Can anyone provide a means to make this faster/remove inefficiencies or any other assistance would be helpful? The code is as follows:
x1=0;
x2=0;
x3=0;
x4=0;
for k=1:1:100
%plot 1
A1=readVoltage(a,'A1');
x1=[x1,A1];
plot(handles.axes1,x1,'LineWidth',2);
grid on;
drawnow;
%plot 2
A2=readVoltage(a,'A2');
x2=[x2,A2];
plot(handles.axes2,x2,'LineWidth',2);
grid on;
drawnow;
%plot 3
A3=readVoltage(a,'A3');
x3=[x3,A3];
plot(handles.axes3,x3,'LineWidth',2);
grid on;
drawnow;
%plot 4
A4=readVoltage(a,'A4');
x4=[x4,A4];
plot(handles.axes4,x4,'LineWidth',2);
grid on;
drawnow;
pause(0.01);
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!