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 vue (au cours des 30 derniers jours)
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 commentaires
APU CHAKRABORTY
APU CHAKRABORTY le 7 Juin 2022
please help me to run this code and animated in same time
VBBV
VBBV le 7 Juin 2022
You can put the code for plot inside the for loop and run it.

Connectez-vous pour commenter.

Réponses (1)

VBBV
VBBV le 7 Juin 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.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by