How do I make a circle move within the specified axes so that it bounces off of the axes?

7 ビュー (過去 30 日間)
Brennan Hudson
Brennan Hudson 2018 年 3 月 26 日
回答済み: Gayatri Menon 2018 年 4 月 9 日
%How do I make a circle move within the specified axes so that it bounces off of the axes? It was suggested to just %use if statements to flip dx and dy from positive to negative or vice versa, however, I'm not sure how to even get %the circle moving on the plot.
r = 1; theta = 0:1:360; x = r*cosd(theta); y = r*sind(theta); plot(x,y);
axis([-10 10 -10 10]) axis equal axis manual

回答 (1 件)

Gayatri Menon
Gayatri Menon 2018 年 4 月 9 日
Hi,
You could use a for loop to create a moving circle. Depending upon your use case, you will have to change some parameter in the equation of the circle in each iteration to create the moving effect, for example, change center, radius etc.The following link has an example which might be helpful for you.
Thanks

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by