Continuous Convolution in Time Domain
19 views (last 30 days)
Show older comments
Hello
I have a signal which is and another one which is and both of them consist of 1e5 points.
I do know that if we convolve these two signals we have 1e5+1e5-1 points for output but I want to see a system which its input has 1e5 points and so for output and I dont know to peak which points.
when I plot the input and output I expect to see that each s(t) should be in synchrony with h(t) cause output should be s(t-500) + s(t-550) but it is not. Also amplitude is not right. I would be very glad if someone can help me fix my problem.
dt = 0.01; % Simulation time step
Duration = 1000; % Simulation length
T = ceil(Duration/dt);
t = (1:T) * dt; % Simulation time points in ms
rho = zeros(size(t));
rho([50000, 55000]) = 1;
K = t/tau_peak .* exp(1-(t/tau_peak));
y = dt*conv(K, rho, 'same');
figure;
plot(t, y)
hold on
plot(t, rho)
Accepted Answer
Paul
on 13 Apr 2022
Edited: Paul
on 10 Oct 2024 at 15:11
Hello @Masoud Nateghi
The code needs to use the full convolution sum to approximate the convolution integral. Also, because the area under the Dirac delta function is 1, which is the height of the Kronecker delta, we don't multiply the convolution sum by dt when one of the functions has only Dirac delta functions, which is confirmed below by finding the closed form expression for the convolution integral. Alternatively, the Kronecker deltas could be multilpled by 1/dt and the covolution sum multiplied by dt as normal, which actually may be a more appealing approach.
dt = 0.01; % Simulation time step
Duration = 1000; % Simulation length
T = ceil(Duration/dt);
The simulaton should start at t = 0
t = (0:T) * dt; % Simulation time points in ms
rho = zeros(size(t));
Need to add 1 here becasue t(1) = 0. Multiply the pulses by 1/dt to account for later multiplication by dt.
rho([50000, 55000]+1) = 1/dt;
tau_peak = 1;
K = t/tau_peak .* exp(1-(t/tau_peak));
Full convolution
y = conv(K, rho)*dt;
But we only need to plot the values of y(t)
figure;
plot(t, y(1:numel(t)))
Zoom in
figure;
plot(t,y(1:numel(t)));
xlim([490 575])
Verify against the closed form solution
syms s(tt) h(tt)
tau_peak = 1;
s(tt) = tt/tau_peak*exp(1-tt/tau_peak)*heaviside(tt);
h(tt) = dirac(tt-500) + dirac(tt-550);
syms tau yy(tt)
yy(tt) = int(h(tau)*s(tt-tau),tau,-inf,inf)
fplot(yy(tt),[490 575])
ylim([0 1.1])
0 Comments
More Answers (0)
See Also
Categories
Find more on Spectral Measurements 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!