座標の範囲や、label、凡例の固定
1 ビュー (過去 30 日間)
表示 古いコメント
for文を回してdrawnowでアニメーションを作ることを考えています。
その時に、タイトルや、凡例、座標の範囲の設定などをfor文に入れてしまうと、とても遅くなるため、
事前にfor文の外で設定し、その設定を固定したまま、for文を回すことはできないでしょうか。
0 件のコメント
回答 (1 件)
Keita Abe
2022 年 10 月 19 日
例えばこんな感じでforループの前に設定を入れるのではどうでしょうか?
theta = linspace(-pi,pi,500);
xc = cos(theta);
yc = -sin(theta);
plot(xc,yc);
axis equal
%%
xt = [-1 0 1 -1];
yt = [0 0 0 0];
hold on
t = area(xt,yt); % initial flat triangle
% title, axis, legend settings
title('hello')
xlim([-2 2])
ylim([-2 2])
legend({'Line', 'Area'})
hold off
for j = 1:length(theta)-10
xt(2) = xc(j); % determine new vertex value
yt(2) = yc(j);
t.XData = xt; % update data properties
t.YData = yt;
drawnow limitrate % display updates
end
0 件のコメント
参考
カテゴリ
Find more on Subplots 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!