Who can help me with my convolution code please?
이전 댓글 표시

t=-5:0.01:5;
y=heaviside(t)-heaviside(t-1);
subplot(3,1,1);
plot (t,y);
legend(‘u(t)-u(t-1)’);
axis([-2 5 -1 1.5]);
z=heaviside(t)-heaviside(t-4);
subplot(3,1,2);
plot (t,z);
legend(‘u(t)-u(t-4)’);
axis([-2 5 -1 1.5]);
답변 (1개)
Sam Chak
2022년 5월 16일
@Loh Sheng Ting, I look at your code directly (that is related to Question b) and it looks okay.
step = 0.01;
t = -5:step:5;
x = 3*(heaviside(t) - heaviside(t - 1));
h = 2*(heaviside(t) - heaviside(t - 4));
subplot(2,1,1);
plot(t, x, 'linewidth', 1.5);
hold on
plot(t, h, '--');
hold off
axis([-2 5 -1 3.5])
ylabel({'$x(t)$'}, 'Interpreter', 'latex')
subplot(2,1,2);
plot(t, x, '--')
hold on
plot(t, h, 'linewidth', 1.5);
hold off
axis([-2 5 -1 3.5])
ylabel({'$h(t)$'}, 'Interpreter', 'latex')
xlabel({'$t$'}, 'Interpreter', 'latex')

댓글 수: 4
Loh Sheng Ting
2022년 5월 16일
Are the Answers helpful in solving your problems? Let me know. Does the plot for c(i) look like this? Please share your lecturer's MATLAB code.
x1 = [0 1/3 2/3 1 4/3 5/3 2]
nx = 0:length(x1)-1;
h1 = ones(1, 5)
nh = 0:length(h1)-1;

Loh Sheng Ting
2022년 5월 16일
Sam Chak
2022년 5월 16일
Are the Answer helpful in solving your problem (b)?
Can you plot and show me
and
first?
I want to check and confirm how to do the convolution.
카테고리
도움말 센터 및 File Exchange에서 Subplots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!