座標の範囲や、label、凡例の固定

4 ビュー (過去 30 日間)
Shunsuke Iwai
Shunsuke Iwai 2022 年 5 月 9 日
回答済み: Keita Abe 2022 年 10 月 19 日
for文を回してdrawnowでアニメーションを作ることを考えています。
その時に、タイトルや、凡例、座標の範囲の設定などをfor文に入れてしまうと、とても遅くなるため、
事前にfor文の外で設定し、その設定を固定したまま、for文を回すことはできないでしょうか。

回答 (1 件)

Keita Abe
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

カテゴリ

Help Center および File Exchangeアニメーション についてさらに検索

Community Treasure Hunt

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

Start Hunting!