I need help writing a program that makes the ball move along the path.

3 vues (au cours des 30 derniers jours)
This is what my codes look likes:
clear all
clc
close all
createWindow(300,600);
obj = drawBall(0,300,5,'y');
x = 0:1:300;
y = 50 * sin(x/(10*pi)) + 100
plot(x,y)
for k = 1:x
xMove(obj,1)
yMove(obj,ystep)
redraw
end
Please help me figure out the ystep. I have no idea how to do it. Thanks in advance!
  3 commentaires
Stephen23
Stephen23 le 24 Oct 2020
John Polo's orginal question retrieved from Google Cache:
I need help writing a program that makes the ball move along the path.
This is what my codes look likes:
clear all
clc
close all
createWindow(300,600);
obj = drawBall(0,300,5,'y');
x = 0:1:300;
y = 50 * sin(x/(10*pi)) + 100
plot(x,y)
for i = 1:x
xMove(obj,1)
yMove(obj,ystep)
redraw
end
Please help me figure out the ystep. I have no idea how to do it. Thanks in advance!
Rena Berman
Rena Berman le 7 Mai 2021
(Answers Dev) Restored edit

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Oct 2020
for k = 1:length(x)-1
xstep = x(k+1)-x(k);
xMove(obj, xstep)
ystep = y(k+1)-y(k);
yMove(obj, ystep)
redraw
end

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by