You are on page 1of 3

Signals and Systems (UG)/ Foundations of Signal Processing (PG) September 23, 2012

Matlab Session 3 Operations on Signals Energy, power calculations of signals Operations like shifting, scaling, folding Convolution

The energy of a signal is defined as

The power of a signal (exists only for periodic signals) is the time average of energy

Using the int and limit function in MATLAB the energy and power of signals can be found out. limit FUNCTION The limit command is used to find out the limit of a symbolic expression. The general syntax is value=limit (F,x,a) where F is the symbolic expression ,x is the free variable/symbol and a is the limit that is

simplify FUNCTION Another useful function is the simplify function which is used to simplify symbolic expressions. The syntax is simplify(S) where S is a symbolic expression. eg: simplify(sin(x)^2 + cos(x)^2) is 1 . Sandeep Joshi

Signals and Systems (UG)/ Foundations of Signal Processing (PG) September 23, 2012 Another way of defining unit step function function[x]=u(t) l=length(t); for i=1:l; if t(i)>0 x(i)=1; else x(i)=0; end end Any function can be expressed in terms of Unit step function, therefore it is important to define a unit step function.
1. Using MATLAB generate x (t) = Acos (wt +) with =/6 radians, A varying between 5 and -5 and T = 0.1 sec. and hence find the signal power and energy. 2. Using MATLAB find the signal energy or power of the following signals: a. x (t) = u(t) b. x (t) = rect(t) c. x [n] =A d. x[n] = A [n]

3. Explore commands 1) syms 2) impz 3) filter

4.
-4 , x[n] = n , 2/n -6 n < 3 , 3n n<-6

Write matlab code for generating and plotting the following sequencesx [-n], x[3-n], x[2n], x[n/2] 5. Generate the given signal x(t)

Hence sketch the following

Sandeep Joshi

Signals and Systems (UG)/ Foundations of Signal Processing (PG) September 23, 2012
1) x(2t) 2) x(2t+3) 3) x(3-t)

conv FUNCTION The conv function is used to convolve two functions in MATLAB. The syntax is C=conv(a,b) Here a and b are vectors of same length. The length of the convolved function is given by length(C)=length(a)+length(b)-1 eg: The code to convolve two gate functions is given below x1 = -2 : 0.01 : 0 ; x2 = 0.01 : 0.01 : 2 ; x3 = 2.01 : 0.01 : 4 ; x = [ x1 x2 x3 ] ; y1 =[ zeros(size(x1)) ones(size(x2)) zeros(size(x3)) ]; plot (x , y1); y2 = [ zeros(size(x1)) ones(size(x2)) zeros(size(x3)) ]; figure, plot (x, y2); x= -4 : 0.01 : 8 ; z = 0.01*conv (y1,y2) ; figure, plot (x,z); This command is used for discrete convolution, to calculate the Continuous time Convolution find a way using the steps followed in analytical calculations.
6. h[n] = [ u[n] u[n 4] ] and input x[n] = [ u[n] u[n 10] ]. Calculate y[n] which is convolution of h[n] and x[n] using matlab. Plot the output. 7. Two systems have Impulse Responses h1[n] = 1/4, 0 n 3 0, otherwise 1/4 , n =0, 2 h2[n] = -1/4 , n =1, 3 0 , otherwise Use matlab command conv to plot first 20 values of step reponse.

Sandeep Joshi

You might also like