Convolution with a time shifted box function
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Measurements and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!