Convolution with a time shifted box function

조회 수: 6 (최근 30일)
Nghi
Nghi 2024년 4월 7일
답변: Paul 2024년 4월 7일
Hello, I have the input:
Its a box funciton x2(t-0.00225) with L = 0.0005 where it's 1 when 0.002 <= t<= 0.0025 and 0 elsewhere. I want to convolve this with the impulse funciton of a low pass filter:
My hand calculation gives the result for when (-0.00225 + t ) > 0 is y(t) = 1 - e^ (0.00225-t)/RC):
And my code is:
Ts=1e-6; % Set up time and frequency variables
t = 0:Ts:0.01-Ts; N = length(t);
fs=1/Ts; F=fs/N; f=(-fs/2):F:(fs/2)-F;
R = 2000; % Resistance
C = 1.5*10^(-8); % Capacitance (15 nF)
RC = R*C; % Time contant
h = (1/RC) .* exp(-t/RC) .* heaviside(t); % Impulse response of RC LPF
x2 = heaviside(t-0.002) - heaviside(t-0.0025); % box function
y2 = conv(h, x2)*Ts;
figure(3) % Plot result
subplot(2,1,2), plot(t, y2(1:N), 'Linewidth', 2.0)
axis([0 0.004 0 1.2])
xlabel('Time, sec', 'Fontsize', 14), ylabel('y_2(t)', 'Fontsize', 14)
grid on
Which has given the graph:
The graph itself seems correct but when substituting random values of t, the graph is incorrect (it should be 1 from 2.5 and beyond, not reducing to 0 like here). Am I missing something here? Maybe in hand calculation it shouldn't be -tau but I have to take into account the -0.00225 shift for tau too? That would create a big e^(0.00225/RC) constant which I'm skeptical
Thank you

채택된 답변

Paul
Paul 2024년 4월 7일
Hi Nghi,
Why should the output of system remain at 1 for t > 2.5? For t > 2.5, the input is 0 and so we'd expect the output to decay to zero from that time because the system is stable.
Also, be careful using heaviside with the defaults in sympref. With those defaults, we have
heaviside(0)
ans = 0.5000
which is not really what you want when using a discrete-time convolution sum with conv to approximate the continuous-time convolution integral. That can be changed with sympref, or write your own unit step function
u = @(t) double(t>=0);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simultaneous and Synchronized Operations에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by