8

Click here to load reader

Matlab 6 Ayush

Embed Size (px)

Citation preview

Page 1: Matlab 6 Ayush

Experiment No.6

Aim: To calculate the convolution integral of two continuous - time signals.

Theory:

Convolution Integral: Convolution of CT Signals

Convolution helps to determine the effect of the system on an input signal. The shifting property of impulses tells us that a signal can be decomposed into an infinite sum (integral) of scaled and shifted impulses. Knowing how a system affects a single impulse, and by understanding the way a signal is comprised of scaled and summed impulses, it seems reasonable that it should be possible to scale and sum the impulse responses of a system in order to determine what output signal will results from a particular input. If one signal has duration of M seconds and other has N seconds then convolution of these two signals will have duration of M+N seconds.

Finding Convolution Integral

Step 1: Define/Sketch x (τ) and h (τ).

Step 2: The impulse response, h (τ) time-reversed or folded to obtain h (-τ).

Step 3: Then h (- τ ) shifted by t to form h (t - τ) = h [-( τ - t)] which is a function of τ with parameter t. Begin with shift t large and negative, i.e., shift h (- τ ) to the far left on the time axis.

Step 4: The signal x ( τ) and h (t - τ) are multiplied together for all values of τ with t fixed at some value.

Step 5: The product x ( τ) h (t- τ) is integrated over all τ to produce a single output value y (t).

Step 6: For Calculating the response of the system over all instants of time, repeat steps 3 to 5 till response at all time instants (t = -∞ to ∞) is obtained.

Symbolic Math Toolbox

The Symbolic Math Toolbox combines the symbolic mathematics and variable-precision arithmetic capabilities of the Maple symbolic engine with MATLAB numeric and visualization capabilities. With the Symbolic Math Toolbox, you can use the MATLAB language and syntax to perform symbolic computations. The toolbox offers more than 100 symbolic functions for performing algebraic, calculus, and integral transform

Page 2: Matlab 6 Ayush

operations. The Symbolic Math Toolbox uses "symbolic objects" produced by the "sym" function.

>> help sym >> help syms

To see help on Symbolic Math Toolbox functions write help sym/function name in command window. For example,

>> help sym/dirac >> help sym/heaviside >> help sym/int

Finding Convolution Integral in MATLAB using Symbolic Math Toolbox

Step 1: Generate x ( τ) and h (t - τ). (Use syms) Step 2: Multiply x ( τ) and h (t - τ). Step 3: Find out limits of integration and use int to integrate product x ( τ) h (t- τ) with respect to τ to produce output, y (t) (Recall pretty, simplify, collect and subs). Step 4: Use ezplot to sketch x (t), h (t) and y (t). Use subplot to show CT signals and their convolution in single figure.

POST LAB EXERCISE:

Q1. Compute the convolution integral y(t)=x(t)*h(t) of the following pairs of signals:

a.) x(t)=exp(-3*t)*u(t), h(t)=u(t+3)

b.)x(t)and h(t) depicted below:

A1.a)

function y=unit(t)y=0.*(t<=0)+1.*(t>0);

function y=conv_lab(x,h)

Page 3: Matlab 6 Ayush

m=length(x);n=length(h);t=m+n-1;X=[x,zeros(1,n-1)];H=[h,zeros(1,m-1)];for i=1:(length(X)) y(i)=X(1:i)*H(i:-1:1)';endend

t=-5:0.001:5;x=exp(-3*t).*unit(t);subplot(2,2,1);plot(t,x);xlabel('time(t)');ylabel('exp(-3*t)*u(t)');title('x(t)');axis([-5 5 -2 2]);h=unit(t+3);subplot(2,2,2);plot(t,h);xlabel('time(t)');ylabel('u(t+3)');title('h(t)');axis([-5 5 -2 2]);y=conv_lab(x,h);subplot(2,1,2);plot(y);xlabel('time(t)');ylabel('x(t)*h(t)');title('x(t)*h(t)');

Page 4: Matlab 6 Ayush

A1.b)

function y=unit(t)y=0.*(t<=0)+1.*(t>0);

function y=delta(t)y=0.*(t<0)+1.*(t==0)+0.*(t>0);

function y=conv_lab(x,h)m=length(x);n=length(h);t=m+n-1;X=[x,zeros(1,n-1)];H=[h,zeros(1,m-1)];for i=1:(length(X)) y(i)=X(1:i)*H(i:-1:1)';endend

t=-5:0.001:5;x=tri(t);subplot(2,2,1);plot(t,x);xlabel('time(t)');

Page 5: Matlab 6 Ayush

ylabel('tri(t)');title('x(t)');axis([-5 5 -2 2]);h1=unit(t)-unit(t-2);h2=delta(t-3);h3=delta(t-4);h=h1+h2+h3;subplot(2,2,2);plot(t,h);xlabel('time(t)');ylabel('h(t)');title('h(t)');axis([-5 5 -2 2]);y=conv_lab(x,h);subplot(2,1,2);plot(y);xlabel('time(t)');ylabel('x(t)*h(t)');title('x(t)*h(t)');

Q2. Consider the series RC circuit and assume that the circuit’s time constant RC =1s. The impulse response of this circuit is. Use convolution to determine the voltage across capacitor, y (t) due to input voltage x (t) = u (t) – u (t -2).

Page 6: Matlab 6 Ayush

A2.

function y=conv_lab(x,h)m=length(x);n=length(h);t=m+n-1;X=[x,zeros(1,n-1)];H=[h,zeros(1,m-1)];for i=1:(length(X)) y(i)=X(1:i)*H(i:-1:1)';endendfunction y=unit(t)y=0.*(t<=0)+1.*(t>0);

t=-5:0.001:5;h=exp(-t).*unit(t);subplot(2,2,1);plot(t,h);xlabel('time(t)');ylabel('exp(-t)*u(t)');title('h(t)');x=unit(t)-unit(t-2);subplot(2,2,2);plot(t,x);xlabel('time(t)');ylabel('u(t)-u(t-2)');title('x(t)');y=conv_lab(x,h);subplot(2,1,2);plot(y);xlabel('time(t)');ylabel('x(t)*h(t)');title('y(t)');

Page 7: Matlab 6 Ayush

Learning Outcomes:

We learnt how to calculate the convolution integral of two continuous - time signals by using some pre-defined functions in MATLAB.