**Logic**

Any LTI system in general can be written as:

y(n)+a_{1}y(n-1)+a_{2}y(n-2)+............ = b_{0}x(n)+b_{1}x(n-1)+........

Frequency response of such a system can be got using the MATLAB command [h,f]=freqz(x,y) where x is the coefficients of x(n) and y is the coefficients of y(n). The command returns the magnitude and phase response to 'h' and the sampling frequency to 'f'. Using "abs (h)" and "angle (h)" commands we can plot the magnitude and response respectively.

Note that "filter" command can't be used here since there is no particular input x(n) is applied to the system. Therefore to find the frequency response of any system like this one given, in general, we go for "freqz" command.

** **

**Algorithm:**

- Input the coefficients of x(n)
- Input the coefficients of y(n)
- Calculate the frequency response using "freqz" command
- Plot the magnitude and phase plot.

** **

**Program**

%Program to find frequency response of a given LTI system

** x=input ('Enter the coefficients of x(n) ');**

** y=input (' Enter the coefficients of y(n)');**

** (h,f)=freqz(x,y); **% to find frequency response

** subplot(2,1,1);**

** plot(f ./pi, abs(h)); **%plot magnitude plot

** ylabel('magnitude');**

** xlabel('numerated frequency');**

**subplot(2,1,2);**

**plot(f./pi, angle(h)); **%plot phase response

**xlabel('normalized frequency');**

**ylabel('phase in radians');**

## No comments:

## Post a Comment

Your Comments... (comments are moderated)