座標の範囲や、label、凡例の固定
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
for文を回してdrawnowでアニメーションを作ることを考えています。
その時に、タイトルや、凡例、座標の範囲の設定などをfor文に入れてしまうと、とても遅くなるため、
事前にfor文の外で設定し、その設定を固定したまま、for文を回すことはできないでしょうか。
0 Kommentare
Antworten (1)
Keita Abe
am 19 Okt. 2022
例えばこんな感じで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 Kommentare
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!