필터 지우기
필터 지우기

How do I continuously plot a graph using the timer function?

조회 수: 3 (최근 30일)
Joseph Willis
Joseph Willis 2017년 4월 15일
답변: Nirav Sharda 2017년 4월 19일
I am attempting to make a side scrolling game from an axes in a GUI, so I need to plot position of objects with respect to time. I have a timer and a start button, but when I call the value of the timer in the edit box, the plot will only plot the first time ( 1 ). How do I plot continuously?
time = str2num(get(handles.TimeEdit,'String'));
y = -.5 * ( 1 )* ((time)^2) + (3)*(time);
x = 2;
plot(x,y,'o')

답변 (1개)

Nirav Sharda
Nirav Sharda 2017년 4월 19일
Once you have the timer object setup which calls a function at every timer period, in that function you can update the 'XData' and 'YData' properties of the axis. Also you have to call 'drawnow' to update the figure. This would look something like:
set(axeshandle, 'Xdata', ..., 'Ydata', ....)
drawnow;
You can refer to this link which talks more about how you can update a plot continuously using a timer object.

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by