Moving point along a rectangular path
Show older comments
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 Comments
Adam Danz
on 17 May 2021
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
on 19 May 2021
Adam Danz
on 19 May 2021
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
on 19 May 2021
Ricardo Duarte
on 19 May 2021
Accepted Answer
More Answers (0)
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!