How to move a circle on a sine curve?
Ältere Kommentare anzeigen
I tried to move the circle on the sine curve by changing the centre of the circle and did the following:
theta =30:330
x=5*cosd(theta)
y=5*sind(theta)
x(301)=0
y(301)=0
x(302)=5*cosd(30)
y(302)=5*sind(30)
h=fill(x,y,'y')
axis ([0,200,0,50])
axis equal
for i=0:200
x1=i+5*cosd(theta)
y1=sind(i)+5*sind(theta)
x1(301)=i
y1(301)=sind(i)
x1(302)=i+5*cosd(30)
y1(302)=sind(i)+5*sind(30)
set(h,'xdata',x1,'ydata',y1)
pause(0.01)
end
But the circle keeps on moving on a straight line although y component of the changing circle should be changing.
Akzeptierte Antwort
Weitere Antworten (1)
Mischa Kim
am 10 Okt. 2014
Bearbeitet: Mischa Kim
am 10 Okt. 2014
Airas, use something like
...
h = fill(x,y,'y');
axis ([0,200,0,50])
axis equal
axis manual
for ii = 0:200
x = x + 1*cosd(ii);
y = y + 1*sind(ii);
set(h,'Vertices', [x(:) y(:)])
pause(0.01)
drawnow
end
1 Kommentar
Airas Akhtar
am 11 Okt. 2014
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!