Try a "pause(0.5)" or something like that in the for loop. Otherwise you only see the last picture.
How to climb stairs?
4 次查看(过去 30 天)
显示 更早的评论
Hello everyone.
I am a begineer of MATLAB programming and I would like to get a circle climbing the stairs that are written as X and Y.
Here is the code so far:
clc
clear
clf
x=[0 0 29 29 58 58 87];
y=[0 0 0 17 17 34 34];
hbead = line(x(1),y(1),'marker','o','markersize',10,'erase','none') ;
htrail = line(x(1),y(1),'marker','.','color','r','erase','none') ;
axis([-10 90 -5 40]);
axis('square');
for k = 1 : 7
set(hbead ,'xdata',x(k),'ydata',y(k));
set(htrail,'xdata',x(k),'ydata',y(k));
drawnow
end
The circle does not move, nor the tail is drawn. The circle should move according to some equations, which describe how the circle moves when it in vertical or horizontal position, what heppens when the center of circle reaches the stair edge and so on. I guess, that these equations should be written in "for" cycle. Am I right?
Could you please help me to understand what do I do wrong?
Thank you.
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!