Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

LAB 2 SOLOUTIONS

PROGRAM 1:
>> num=[0.634 0 0.634]; % find by analysis of difference equation
>> denom=[1 0 -0.268]; % find by analysis of difference equation
>> x=[1 zeros(1,31)]; % impulse fn to be input to the filter
>> y=filter(num, denom,x); % a filter with numn and denom as specs this gives the responce
>> stem(y); grid; % plot the amplitude response only

>> figure; impz(num,denom);grid; % this also plots the impulse and step response of filter with num and denom as specs
but here matlab gives the filter an input by itself

>> figure;step(num,denom);grid; % this also gives the step respnce in the same way as above

>> fvtool(num, denom);% this plots the phase responce of the filter

PROGRAM 2:
>> n=0:99; % no of samples of input to be included
>> x1=cos(2*pi*0.03*n); % low frequency DT sinusoid
>> x2=cos(2*pi*0.51*n); % high frequency DT sinusoid for high freq sinusoids n shuld be smal to avoid conjustion
>> x=x1+x2; % input to be given to the filter
>> M=5; % 5-tap MA system "the more the values of M the more is the data loss
>> num= ones(1,M)/M; % numerator coefficents
>> denom=1;% since it's FIR therefore its denom cofficient is 1
>> y=filter(num,denom,x); % passing x as input to the filter
>> % displaying the inputs and outputs
>> subplot(221);plot(n,x1);axis([0 100 -2 2]); % ploting the input x1
>> subplot(222);plot(n,x2);axis([0 100 -2 2]); % ploting the input x2
>> subplot(223);plot(n,x);axis([0 100 -2 2]); % ploting the input x
>> subplot(224);plot(n,y);axis([0 100 -2 2]); % ploting the amplitude responve of filter

QUESTION 1:
>> num=[0.5 0.27 0.77];denom=1;
>> n=[0:299];
>> x=cos(0.078125*pi.*n);
>> y=filter(num,denom,x);
>> stem(y);grid;

Question 2 using fvtool command find responses of MA


>> fvtool(num,denom)

QUESTION 3 : DESIGN MA FOR M=11 AND FIND RESPONCES

By changing the value of M the ripples of amplitude response are removed

You might also like