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

3 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2020-10-24
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!

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2020-10-23
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

更多回答(0 个)

类别

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