Effacer les filtres
Effacer les filtres

How to climb stairs?

6 vues (au cours des 30 derniers jours)
Nerramus
Nerramus le 27 Nov 2016
Réponse apportée : Nick le 27 Nov 2016
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.

Réponses (1)

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

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by