필터 지우기
필터 지우기

How to climb stairs?

조회 수: 1 (최근 30일)
Nerramus
Nerramus 2016년 11월 27일
답변: Nick 2016년 11월 27일
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.

답변 (1개)

Nick
Nick 2016년 11월 27일
Try a "pause(0.5)" or something like that in the for loop. Otherwise you only see the last picture.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by