how to sum unit function and step function
11 views (last 30 days)
I want to calculate the convolution of x(t) and h(t).
Here is my code :
t = [ -10 : 0.01 : 10 ];
xt = ( t >= -2 ) & ( t <= 2) + (t == 1)
ht = ( t >= -1 ) & ( t <= 2) + 2*(t == 0) + (t == 3)
yt = conv(xt,ht,'same');
t1 = [-inf, inf];
I'm not sure that xt and ht are correct.
Moreover, there is an error with last line.
Ajay Pattassery on 4 May 2020
I assume you are trying to do the convolution of xt, ht as attached in the image.
t = ( -10 : 0.01 : 10 );
xt = (( t >= -2 ) & ( t <= 2)) + (t == 1);
ht = (( t >= -1 ) & ( t <= 2)) + 2*(t == 0) + (t == 3);
yt = .01*conv(xt,ht,'same');
I have just edited your above code.
If you are doing convolution of continuous signals by approximating as above in MATLAB, you need to multiply the output of conv with dt. In your case .01. What you are basically doing is approximating the continuous signal with boxes of width .01 and doing the discrete convolution. Hence while doing convolution, the integration can be achieved by mulitplying with dt.