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

조회 수: 3 (최근 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

답변 (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 CenterFile Exchange에서 2-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