필터 지우기
필터 지우기

座標の範囲や、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 CenterFile Exchange에서 アニメーション에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!