How to set axis limit as a function of time with fanimator

10 ビュー (過去 30 日間)
Seonghoon Noh
Seonghoon Noh 2020 年 9 月 11 日
編集済み: Christopher Creutzig 2021 年 1 月 19 日
I have an object I would like to center in the figure frame when using fanimator. Say the x-position of the object is simply
x = @(t) 2*t
Then, I would like to be able to use xlim in a way like
hold on;
fanimator(@(t) plot(x(t),y(t)));
xlim([-5 5] + x(t));
ylim([0 3])
hold off;
However, x is just a function handle and t is undefined. How can I achieve this?

回答 (2 件)

Ayush Gupta
Ayush Gupta 2020 年 9 月 21 日
I have brought this issue to the notice of our developers. They will investigate the matter further.

Christopher Creutzig
Christopher Creutzig 2021 年 1 月 19 日
編集済み: Christopher Creutzig 2021 年 1 月 19 日
Unfortunately, it is currently not possible to animate xlim/ylim/zlim with fanimator. Changing that would not be easy, based on the structure of graphics objects inside a figure.
For animations requiring this kind of parameters, please use one of the other ways of animating MATLAB graphics as described on https://www.mathworks.com/help/matlab/animation-1.html; for example, using a loop:
for t=0:.1:5
plot(x(t),y(t),'*');
xlim([-5 5] + x(t));
ylim([0 3]);
pause(0.1);
end

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by