이신플러스의 달콤쌉싸름한 낙원

반응형

해당 게시글은 수식표시가 에러로 인해정상표기되고 있지 않은 점 양해 부탁드립니다.


Chapter 8

 

8.1  

         

       

8.2

a.

   

 

b.

freqz([0.3375 0.3375],[1 -0.3249],512,200)

            

 

8.3

a.

   

    

b.

   >> freqz([0.6225 -0.6225],[1 -0.3594],512,200)

        

 

 

8.4

a. 

     b =

     

b.

   >> freqz([0.6340 0 0.6340],[1 0 0.2679],512,120)

    

 

8.5

a.  

       

     

b.

     >> freqz([0.2113 0 -0.2113],[1 -0.8165 0.5774],512,120)

 

 

 

 

                 

 

8.6

a.

    

    

b.

>> freqz([0.4005 0.4005],[1 -0.1989],512,8000)

            

 

8.7

a.

  

   

b.

 >> freqz([0.1867 0.3734 0.1867],[1 -0.4629 0.2097],512,8000)

                 

8.8

a.

  

   

b.

>> freqz([0.1667 -0.5 0.5 -0.1667],[1 0 0.3333 0],512,8000)

       

 

8.9

a.

   

    

b.

>> freqz([0.0730 0 -0.0730],[1 0 0.8541],512,8000)

            

 

 

 

8.10

a.

   

    

b.

>> freqz([0.9266 -0.2899 0.9266],[1 -0.2899 0.8532],8000,8000)

            

            

8.11

a.

    

    

b.

>> freqz([0.5667 0.5667],[1 0.1354],512,8000)

                   

8.12

a.

   

    

b.

>> freqz([0.2430 0.4861 0.2430],[1 -0.2457 0.2755],512,8000)

 

            

 

8.13

a.

     

     

b. 

>> freqz([0.1321 -0.3964 0.3964 -0.1321],[1 0.3432 0.6044 0.2041],512,8000)

                 

 

8.14

a.

   

    

b.

>> freqz([0.1815 0 -0.1815],[1 -0.6265 0.6370],512,8000)

            

            

8.15

a.

   

    

b.

>> freqz([0.9609 0.7354 0.9609],[1 0.7354 0.9217],512,8000)

            

                 

8.16

a. 

    

     

b. 

>> freqz([0.0380 0.1519 0.2278 0.1519 0.0380],[1 -0.9784 0.7901 -0.2419 0.0377],512,8000)

            

8.17

a.

    

     

b.

>> freqz([0.0242 0.0968 0.1452 0.0968 0.0242],[1 -1.5895 1.6690 -0.9190 0.2497],512,8000)

                 

 

8.18

 

a. 

    

     

b.

>> freqz([0.00767 0 -0.01534 0 0.00767],[1 -1.4428 2.2935 -1.2918 0.8027],512,8000)

 

8.19     

a.  

     

     

b. and c.

---------------------------------------------------------------------------------------------------

 f=0:0.1:5;T=0.1                        % frequency range and sampling interval

  w=2*pi*f;                                 %  frequency range in radians/sec

  hs=freqs([10], [1 10],w);              % analog magnitude frequency response

  phis=180*angle(hs)/pi;

% for the z-transfer function H(z)

  hz=freqz([1],[1 -0.3967],length(w));   % digital magnitude frequency response

   phiz=180*angle(hz)/pi;

%plot magnitude and phase responses.

  subplot(2,1,1), plot(f,abs(hs),'kx',f, abs(hz),'k-'),grid; axis([0 5 0 2]);

  xlabel('Frequency (Hz)'); ylabel('Mag. Responses')

  subplot(2,1,2), plot(f,phis,'kx',f, phiz,'k-'); grid;

  xlabel('Frequency (Hz)');  ylabel('Phases (deg.)');

-----------------------------------------------------------------------------------------

            

 

8.20

a.

    

    

b. and c.

----------------------------------------------------------------------------------------------------

 f=0:0.1:5;T=0.1;  % initialize analog frequency range in Hz and sampling interval

  w=2*pi*f;           % convert the frequency range to radians/second

  hs=freqs([1], [1 3 3],w); % calculate analog filter frequency responses

  phis=180*angle(hs)/pi;

  % for the z-transfer function H(z)

% calculate digital filter frequency responses

  hz=freqz([0.0086],[1 -1.7326 0.7408],length(w));

  phiz=180*angle(hz)/pi;

% plot magnitude and phase responses

  subplot(2,1,1), plot(f,abs(hs),'kx',f, abs(hz),'k-'),grid;

  xlabel('Frequency (Hz)'); ylabel('Magnitude Responses')

  subplot(2,1,2), plot(f,phis,'kx',f, phiz,'k-'); grid;

  xlabel('Frequency (Hz)'); ylabel('Phases (degrees)')

----------------------------------------------------------------------------------------------------

                 

8.21

a.

   

    

b. and c.

---------------------------------------------------------------------------------------------------

 f=0:0.1:5;T=0.1;  % initialize analog frequency range in Hz and sampling interval

  w=2*pi*f;           % convert the frequency range to radians/second

  hs=freqs([1 0], [1 4 5],w); % calculate analog filter frequency responses

  phis=180*angle(hs)/pi;

  % for the z-transfer function H(z)

% calculate digital filter frequency responses

  hz=freqz([0.1 -0.09781],[1 -1.6293 0.6703],length(w));

  phiz=180*angle(hz)/pi;

% plot magnitude and phase responses

  subplot(2,1,1), plot(f,abs(hs),'kx',f, abs(hz),'k-'),grid;

  xlabel('Frequency (Hz)'); ylabel('Magnitude Responses')

  subplot(2,1,2), plot(f,phis,'kx',f, phiz,'k-'); grid;

  xlabel('Frequency (Hz)'); ylabel('Phases (degrees)')

-----------------------------------------------------------------------------------------------------------------------

                 

 

8.22

                 

                 

 

8.23

 

 

8.24

   

 

8.25 

 

 

8.26

 

8.27

 

8.28

a.

             

                 

 

                 

b.

Direct-form I:

            

 

Direct-form II:

            

            

 

 

8.29

a.

        

 

b. for section 1:

                             

   for section 2:  

                             

 

8.30

Chebyshev notch filter: order =2

          

    

-------------------------------------------------------------------------------------

fs=8000;T=1/fs;

w0=2*pi*360; wa0=(2/T)*tan(w0*T/2);

wL=2*pi*330; waL=(2/T)*tan(wL*T/2);

wH=2*pi*390; waH=(2/T)*tan(wH*T/2);

waaL=wa0*wa0/waH;BW1=waH-waaL

waaH=wa0*wa0/waL;BW2=waaH-waL

[B,A]=lp2bs(2.8628,[1 2.8628],wa0,BW2);

[b,a]=bilinear(B,A,fs)

freqz(b,a,8000,8000);

-------------------------------------------------------------------------------

 

8.31      Chebyshev notch filter 1: order =2

              

           

 

See Problem 8.31.

         Chebyshev notch filter 2: order =2

                   

              

------------------------------------------------------------------------------------

fs=8000;T=1/fs;

w0=2*pi*1080; wa0=(2/T)*tan(w0*T/2);

wL=2*pi*1050; waL=(2/T)*tan(wL*T/2);

wH=2*pi*1110; waH=(2/T)*tan(wH*T/2);

waaL=wa0*wa0/waH;BW1=waH-waaL

waaH=wa0*wa0/waL;BW2=waaH-waL

[B,A]=lp2bs(2.8628,[1 2.8628],wa0,BW2);

[b,a]=bilinear(B,A,fs)

freqz(b,a,8000,8000);

------------------------------------------------------------------------------------

 

8.32

               

  radians/se.

              radians/sec

              and  dB

            

               Choose

Butterworth filter order = n=4

            

-------------------------------------------------------------------------------------------

fs=10000;T=1/fs;

wd=2*pi*3000; wa=(2/T)*tan(wd*T/2);

[B,A]=lp2lp(1,[ 1 2.6131 3.4142 2.6131 1],wa);

[b,a]=bilinear(B,A,fs)

freqz(b,a,512,fs);

-----------------------------------------------------------------------------------------

 

 

 

 

 

 

8.33

             radians/second,

 radians/second, and  sec.

  radians/se.

              radians/sec

              and  dB

                                                     

                 

             Chebyshev filter order = 4;

            

---------------------------------------------------------------------------------------------------

fs=10000;T=1/fs;

wd=2*pi*3000; wa=(2/T)*tan(wd*T/2);

[B,A]=lp2lp(0.2456,[ 1 0.9528 1.4539 0.7426 0.2756],wa);

[b,a]=bilinear(B,A,fs)

freqz(b,a,512,fs);

-----------------------------------------------------------------------------------------------------------------------

 

8.34    and

         

 

>> r=1-500*pi/8000;

>> theta=1750*2*pi/8000;

>> K=(1-r)*sqrt(1-2*r*cos(2*theta)+r*r)/(2*abs(sin(theta)));

r = 0.8037

K =0.1771

-2*r*cos(theta)

ans = -0.3136

 

            

 

 

 

8.35  

              

      

Fixing  

            

Fixing ,

            ,

We choose a smaller bandwidth for aggressive design:

             ,

            

 and  dB

            

               Choose

 

             filter order 2n= 4

 

------------------------------------------------------------------------------------------------------------------------

fs=8000;T=1/fs;

wL=2*pi*1500; waL=(2/T)*tan(wL*T/2);

wH=2*pi*2000; waH=(2/T)*tan(wH*T/2);

wa0=sqrt(waL*waH); BW=waH-waL

[B,A]=lp2bp(1,[1 1.4142 1],wa0,BW);

[b,a]=bilinear(B,A,fs)

freqz(b,a,512,8000);

--------------------------------------------------------------------------------------------------------------------------

 

8.36

 a.

 

            

            

 

b. 

            

 

                 

 

 

 

 

 

 

 

 

 

 

c.

            

---------------------------------------------------------------------------------------------------

fs=44100;T=1/fs;

wd=2*pi*1000; wa=(2/T)*tan(wd*T/2);

[B,A]=lp2lp(1,[ 1 2 2 1],wa);

[bL,aL]=bilinear(B,A,fs)

freqz(bL,aL,512,fs);

[hL,ff]=freqz(bL,aL,512,fs);

figure

[B,A]=lp2hp(1,[ 1 2 2 1],wa);

[bH,aH]=bilinear(B,A,fs)

freqz(bH,aH,512,fs);

[hH,ff]=freqz(bH,aH,512,fs);

figure

H=abs(hL)+abs(hH);

plot(ff,20*log10(abs(hL)),ff,20*log10(abs(hH)),'-.', ff,20*log10(H));

-----------------------------------------------------------------------------------------------------

 

8.37   

a. 

  

b.

 

            

c.

>> fs=8000; T=1/fs;

>> t=0:T:0.01;

>> x=zeros(1,length(t)); x(1)=1;

>> y=filter([0 0.5878],[1 -1.6180 1],x);

>> plot(t,y);grid;xlabel('Time (sec.)');ylabel('800-Hz tone');

                          

 

8.38

a.

                  

b.         

           

            

c.

-------------------------------------------------------------------------------------------

fs=8000;T=1/fs;                               

x=zeros(1,205);x(1)=1;                                             

y1=filter([0 sin(2*pi*770/fs)],[1 -2*cos(2*pi*770/fs) 1],x);   

y2=filter([0 sin(2*pi*1336/fs) ],[1 -2*cos(2*pi*1336/fs) 1],x);

y=y1+y2;                        

plot(N,y,'k');grid

ylabel('y(n) DTMF: number 5');xlabel('Sample number n')

------------------------------------------------------------------------------------------

            

8.39                

                                                                                    

         for

                          

                  with ,

         

              

a.     ;  b. ;  c.

         for

                             

            with ,

          

   d. ; e. ; f.

 

8.40

, and

a. 

             and

b.

  with , for  

  with , for

c.

                          

                                    

and

                                  

                                  

d.

--------------------------------------------------------------------------------------------

fs=8000;T=1/fs;                               

x=zeros(1,205);x(1)=1;                                             

y1=filter([0 sin(2*pi*770/fs)],[1 -2*cos(2*pi*770/fs) 1],x);   

y2=filter([0 sin(2*pi*1336/fs) ],[1 -2*cos(2*pi*1336/fs) 1],x);

y=y1+y2;                        

xDTMF=[y 0];

v20=filter(1,[1 -2*cos(2*pi*20/205) 1],xDTMF);

v34=filter(1,[1 -2*cos(2*pi*34/205) 1],xDTMF);

X20=sqrt(v20(206)^2+v20(205)^2-2*cos(2*pi*20/205)*v20(206)*v20(205));

X34=sqrt(v34(206)^2+v34(205)^2-2*cos(2*pi*34/205)*v34(206)*v34(205));

A20=2*X20/205

A34=2*X34/205

-----------------------------------------------------------------------------------------------

 A20 = 0.8818

 A34 = 0.9147

 

8.41

a.

--------------------------------------------------------------------------------------------------

n=0:N-1;

sample=1.2*sin(2*pi*1000*n/10000)-1.5*cos(2*pi*4000*n/10000);

%direct-form I implementation

 x=[0 0 0 0 0]; %input buffer [x(n) x(n-1) ..]

 y=[0 0 0 0 0]; %output buffer [y(n) y(n-1) ... ]

 b=[0.1103 0.4412 0.6618 0.4412 0.1603]; %Numerator coefficients [b0 b1 ...]

 a=[1 0.1509 0.9041 -0.1619 0.1872]; %Denominator coefficients [1 a1 ...]

 KKb=length(b); KKa=length(a);

 for n=1:1:length(sample) % loop processing

     for k=KKb:-1:2        % shift input by one sample

         x(k)=x(k-1);

     end

     x(1)=sample(n);     % get new sample

     for k=KKa:-1:2        % shift input by one sample

         y(k)=y(k-1);

     end

     y(1)=0;             % perform IIR filtering

     for k=1:1:KKb

         y(1)=y(1)+b(k)*x(k);

     end

     for k=2:1:KKa

         y(1)=y(1)-a(k)*y(k);

     end

     out(n)=y(1); %send filtered sample to the output array

 end

 subplot(2,1,1);plot(sample);grid;axis([0 500 -3 3]);

 xlabel('Smaple number n');ylabel('Sample(n)');

 subplot(2,1,2);plot(out);grid;axis([0 500 -3 3]);

 xlabel('Smaple number n');ylabel('Out(n)');

-------------------------------------------------------------------------------------------

                         

b.

-----------------------------------------------------------------------------------------------

n=0:N-1;

sample=1.2*sin(2*pi*1000*n/10000)-1.5*cos(2*pi*4000*n/10000);

%direct-form II implementation

 w=[0 0 0 0 0]; %filter states [w(n) w(n-1) ..]

 b=[0.1103 0.4412 0.6618 0.4412 0.1603]; %Numerator coefficients [b0 b1 ...]

 a=[1 0.1509 0.9041 -0.1619 0.1872]; %Denominator coefficients [1 a1 ...]

 KKb=length(b); KKa=length(a); KKw=length(w);

 for n=1:1:length(sample) % loop processing

     for k=KKw:-1:2        % shift input by one sample

         w(k)=w(k-1);

     end

     w(1)=sample(n);    

     for k=2:1:KKa             

         w(1)=w(1)-a(k)*w(k);   %IIR filtering

     end

     sum=0;

     for k=1:1:KKb

         sum=sum+b(k)*w(k);    %FIR filtering

     end

     out(n)=sum; %send filtered sample to the output array

 end

 subplot(2,1,1);plot(sample);grid;axis([0 500 -3 3]);

 xlabel('Smaple number n');ylabel('Sample(n)');

 subplot(2,1,2);plot(out');grid;axis([0 500 -3 3]);

 xlabel('Smaple number n');ylabel('Out(n)');

-------------------------------------------------------------

    Plots are the same as ones in (b).

반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading