Borrar filtros
Borrar filtros

How to climb stairs?

6 visualizaciones (últimos 30 días)
Nerramus
Nerramus el 27 de Nov. de 2016
Respondida: Nick el 27 de Nov. de 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.

Respuestas (1)

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

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by