Moving point along a rectangular path
显示 更早的评论
Dear all,
I would like create a point that moves along a path (as in the figure) knowing only the initial and the final position of that point.

After that I would like to plot that movement in a figure.
Thanks in advance for your help.
Best wishes
6 个评论
Adam Danz
2021-5-17
What have you tried so far?
What ideas do you have to conceptually address this?
For example, if you know the starting and end coordinate, you don't the height and width of the outer rectangle.
Let's say it should take 4 direction reversals as shown in your image. How would you compute the width of each reversal? (hint: outer rectangle size divided by number of reversals).
What would be the next step to solve?
Ricardo Duarte
2021-5-19
Adam Danz
2021-5-19
Good start.
The code breaks on the first iteration of the i-loop at this line
xlim([x1-1 x2+1]); ylim([y1-1 y3+1]);
Error using xlim (line 31)
Limits must be a 2-element vector of increasing numeric values.
Error in **** (line 228)
xlim([x1-1 x2+1]); ylim([y1-1 y3+1]);
which makes sense since [x1-1 x2+1] is [-991 -1009].
Tell me more about the goal. Is the problem that the velocity of the ball is not constant? Is the problem that you'd like to define a specific velocity? If so, we'll need a lot more information about the specifics.
Ricardo Duarte
2021-5-19
Ricardo Duarte
2021-5-19
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Animation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!