How to plot three different graphs in same window using subplots , animated line and adpoints . I have submitted my code in text box please help to run this three graphs

1 回表示 (過去 30 日間)
clc; close all;
t = -3:0.01:3;
x=@(t) exp(-t).*(t>0)+ 0.5*(t==0);
xa=x(t);
xe=( x(t)+x(-t))/2;
x0=(x(t)-x(-t))/2;
subplot(1,1,1)
curve1 = animatedline('LineWidth', 2);
axis([-3 3 -1 1])
grid on
xlabel('t')
ylabel('Amplitude')
title('orginal signal')
hold on
plot(t,xa);
subplot(1,2,1)
curve2 = animatedline('LineWidth', 2);
axis([-3 3 0 1])
grid on
xlabel('t')
ylabel('Amplitude')
title('Continous even signal')
hold on
plot(t,xe);
subplot(1,2,2)
curve3 = animatedline('LineWidth', 2);
axis([-3 3 -1 1])
grid on
xlabel('t')
ylabel('Amplitude')
title('continous odd signal')
hold on
plot(t,x0);
for i = 1: length(t)
addpoints(curve1, t(i), xa(i));
addpoints(curve2, t(i), xe(i));
addpoints(curve3, t(i), x0(i));
drawnow
end
  2 件のコメント
APU CHAKRABORTY
APU CHAKRABORTY 2022 年 6 月 7 日
please help me to run this code and animated in same time
VBBV
VBBV 2022 年 6 月 7 日
You can put the code for plot inside the for loop and run it.

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

回答 (1 件)

VBBV
VBBV 2022 年 6 月 7 日
clc; close all;
t = -3:0.01:3;
x=@(t) exp(-t).*(t>0)+ 0.5*(t==0);
xa=x(t);
xe=( x(t)+x(-t))/2;
x0=(x(t)-x(-t))/2;
subplot(3,1,1) % change this
curve1 = animatedline('LineWidth', 2);
axis([-3 3 -1 1])
grid on
xlabel('t')
ylabel('Amplitude')
title('orginal signal')
hold on
plot(t,xa);
subplot(3,1,2) % change this
curve2 = animatedline('LineWidth', 2);
axis([-3 3 0 1])
grid on
xlabel('t')
ylabel('Amplitude')
title('Continous even signal')
hold on
plot(t,xe);
subplot(3,1,3) % change this
curve3 = animatedline('LineWidth', 2);
axis([-3 3 -1 1])
grid on
xlabel('t')
ylabel('Amplitude')
title('continous odd signal')
hold on
plot(t,x0);
for i = 1: length(t)
addpoints(curve1, t(i), xa(i));
addpoints(curve2, t(i), xe(i));
addpoints(curve3, t(i), x0(i));
drawnow
end
Change the subplot layout to include all in one window.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by