Azzera filtri
Azzera filtri

Convolution with a time shifted box function

9 visualizzazioni (ultimi 30 giorni)
Nghi il 7 Apr 2024
Risposto: Paul il 7 Apr 2024
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

Risposta accettata

Paul il 7 Apr 2024
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
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);

Più risposte (0)




Community Treasure Hunt

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

Start Hunting!

Translated by