understanding convolution

Status
Not open for further replies.
Yes, of course. I was judging your answer partially based on your plot. Apparently you made two mistakes, which offset each other. You incorrectly calculated the answer for region 2 to be 8τ-12, but then incorrectly plotted this as if it were 8τ-4. However, the latter is the correct answer, so your final plot is correct.

If you make mistakes like that on the test, pray that your teacher misses details as well as i do.
 
Hi

I was learning to do convolution in Matlab graphically and found the linked document on the net. Could you please help me with this query? If you can't view the image, then please use these details, username: imgshack4every1, and password: imgshack4every1. Thanks a lot.

Regards
PG
 
The formula for 'a' they have is just h(t) but shifted by t. For each case of "partial-overlap" and "complete-overlap" they've had to explicitly write the values for r.

In that formula, the t is tau and r is t So.. a = r + 1 - t (which is what they've written), might make more sense as h = t + 1 - tau (with tau = 0.6 or 1.6 as in their examples, and t is the range previously specified by r)

Here's the animation of the convolution, it's pretty amazing CGI - try not to get too excited ;P
Code:
%%
taustep = 0.001;

% the x(t) part
tau = -5:taustep:5;
x = tau >= 0 & tau <= 2;

% the h(t) part
h = (tau >= 0 & tau <= 1) .* (1 - tau);

% plot them
figure(1), plot(tau, x, '-', tau, h, ':');

% for the convolution, we want to reverse h(t) and animate it...
tVals = -5:.05:5;
convolveResult = zeros(1, length(tVals));
for ti=1:length(tVals)
    t = tVals(ti);
    
    h = ((t - tau) >= 0 & (t - tau) <= 1) .* (1 - (t - tau));
    
    figure(2), subplot(211), plot(tau, x, '-', tau, h, ':');
    hold on, area(tau(x ~= 0), h(x ~= 0)), hold off;
    ylabel('f(t)');
    
    overlap = x(x ~= 0) .* h(x ~= 0);
    convolveResult(ti) = sum(overlap) * taustep;
    subplot(212), plot(tVals, convolveResult), axis([-5 5 0 1]);
    ylabel('integ{ h(t-tau) * x(t-tau) }');
    
    pause(0.1)
end
 
Thank you, Doug.

Perhaps, I should have posted this problem in the other thread specifically created for Matlab related problems. But anyway, that animation was really cool. Did you code it yourself?

In the formula, a = (1/T) * (r+1) - (t/T), I think "T" is width of the base of triangle, i.e. "1" in this case. You are right in saying that the formula for "a" is simply h(t) shifted by "t". I was wondering why they would include "T" in the formula and apparently when "T" is not equal to "1" then you can't just say that "a" is just another representation of h(t) with shift "t", it's would be completely something different. Suppose, T=2, then a = (1/2) * (r+1) - (t/2). Could you please elaborate on this? Thanks.

Regards
PG
 
Last edited:
>> But anyway, that animation was really cool. Did you code it yourself?
Yes. To animate a series of plots, you can just draw a plot from the sequence, call 'pause(1/framerate)', then repeat.

>> In the formula, a = (1/T) * (r+1) - (t/T), I think "T" is width of the base of triangle, i.e. "1" in this case. You are right in saying that the formula for "a" is simply h(t) shifted by "t". I was wondering why they would include "T" in the formula and apparently when "T" is not equal to "1" then you can't just say that "a" is just another representation of h(t) with shift "t", it's would be completely something different. Suppose, T=2, then a = (1/2) * (r+1) - (t/2). Could you please elaborate on this? Thanks.
It's not "a = (1/2) * (r+1) - (t/2)", it's "a = (1/2) * r + 1 - (t/2)"

Try expanding 'a':
for the 2nd example, a = r/T + 1 - t/T, where r = t-T:t;
therefore
a = (t-T:t)/T + 1 - t/T = t/T-1:t/T + 1 - t/T (expand the /T)
a = 0-1:0 + 1 (add the "-t/T" to the range)
a = -1:0 + 1 = 0:1 --> this is a ramp having a slope of 1, plotted in the region of [x-axis] t-T:t (i.e. 0.6 to 1.6). T is not even in the final result. If you double T, you will still have a triangle with height from 0 to 1, but it will be in the region of t-2 to t --> that means it's been scaled.

for the 1st example, r=0:t, so
a = (0:t)/T + 1 - t/T = 0:t/T + 1 - t/T
a = -t/T:0 + 1 = -t/T+1:1 plotted in the region of [x-axis] 0:t (i.e. 0:0.5)
changing T will scale the result here too.

Bear in mind that if you change T, you're changing the original definition for h(t).
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…