フィルターのクリア

How to make animation of 2D plot

24 ビュー (過去 30 日間)
Telema Harry
Telema Harry 2021 年 8 月 30 日
コメント済み: Telema Harry 2021 年 8 月 30 日
Hi,
I am trying to plot a 2D animation but my code is not giving the expected result.
I have attached my test data. I will appreciate any help.
load('test.mat');
points = size(output,1);
xmin = 0;
xmax = max(t);
ymin = 0;
ymax = max(output(:,7)) + 50;
q = 1;
% anim = zeros(1,points);
figure
title('Animation')
axis([xmin xmax ymin ymax])
for z = 1:1: points
plot(t(z), output(z,7),'o', 'MarkerSize', 10, 'MarkerFaceColor', 'b', 'MarkerEdgeColor','b')
anim(q) = getframe;
q = q + 1;
end

採用された回答

Chunru
Chunru 2021 年 8 月 30 日
load('test.mat');
points = size(output,1);
t=1:points; % use your t here
xmin = 0;
xmax = max(t);
ymin = 0;
ymax = max(output(:,7)) + 50;
q = 1;
% anim = zeros(1,points);
figure
title('Animation')
h = plot(nan, nan, 'o', 'MarkerSize', 10, 'MarkerFaceColor', 'b', 'MarkerEdgeColor','b');
axis([xmin xmax ymin ymax])
for z = 1:1: points
%plot(t(z), output(z,7),'o', 'MarkerSize', 10, 'MarkerFaceColor', 'b', 'MarkerEdgeColor','b');
h.XData = t(z);
h.YData = output(z,7);
drawnow
%pause(0.01);
%anim(q) = getframe;
q = q + 1;
end
  1 件のコメント
Telema Harry
Telema Harry 2021 年 8 月 30 日
Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by