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

2 Ansichten (letzte 30 Tage)
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

Antworten (1)

VBBV
VBBV am 7 Jun. 2022
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.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by