?? poly2c.m
字號:
function poly2
% poly2 forms a recursive fifth order polyphase filter and examines a number of its properties
clg;
a0=input(' enter a0 coefficient of path 0 (eg 0.164 or .190) > ') ;
a1=input(' enter a1 coefficient of path 1 (eg 0.624 or .659) > ') ;
a0=-a0;a1=-a1;
aa1=[1 0 a0];
bb1=[a0 0 1];
aa2=[1 0 a1 0];
bb2=j*[0 a1 0 1];
cc1=[1 0 0];
dd1=[0 0 1];
cc2=[1 0 0 0];
dd2=j*[0 0 0 1];
[h1,w]=freqz(bb1,aa1,200);
phi1=unwrap(angle(h1))*180/pi;
plot(w/(2*pi),phi1);
hold on
[h1r,w]=freqz(dd1,cc1,200);
phi1r=unwrap(angle(h1r))*180/pi;
plot(w/(2*pi),phi1r,':c');
grid;
xlabel('normalized frequency')
ylabel('phase shift in degrees')
[h2,w]=freqz(bb2,aa2,200);
phi2=unwrap(angle(h2))*180/pi;
[h2r,w]=freqz(dd2,cc2,200);
phi2r=unwrap(angle(h2r))*180/pi;
plot(w/(2*pi),phi2r,':c');
plot(w/(2*pi),phi2);
hold off
pause
h3=0.5*(h1+h2);
h4=0.5*(h1-h2);
plot(w/(2*pi),20*log10(abs(h3)));hold;
plot(w/(2*pi),20*log10(abs(h4)),':c');hold
grid
v=[0 0.5 -80 0];
axis(v);
xlabel('normalized frequency');
ylabel('log-magnitude (dB)');
pause
num=[a0 j*a1 (1+a0*a1) j*(1+a0*a1) a1 j*a0];
den=[1 0 (a0+a1) 0 (a0*a1) 0];
zplane(num,den);
pause;
[h,t]=impz(num,den);
subplot(2,1,1);stem(t,real(h));xlabel('time');ylabel('amplitude');title(' real part of h(t)');
subplot(2,1,2);stem(t,imag(h));xlabel('time');ylabel('amplitude');title(' imag part of h(t)');
pause;
x=sin(2*pi*(0:255)*0.1);
y=conv(x,h);
subplot(2,1,1);plot(real(y));xlabel('time');ylabel('amplitude');title(' real part of y(t)');
subplot(2,1,2);plot(imag(y));xlabel('time');ylabel('amplitude');title(' imag part of y(t)');
pause;clg
plot(y);title('real y(t) vrs imag y(t)');hold;pause;plot(y(1:15),'c');pause
sz1=size(x);nn1=sz1(2);
ww1=hanning(nn1)';
sz2=size(y);nn2=sz2(2);
ww2=hanning(nn2)';
fx=(abs(fftshift(fft(ww1.*x,1024))));
fy=(abs(fftshift(fft(ww2.*y,1024))));
subplot(2,1,1);plot(-0.5:1/1024:.5-1/1024,fx);xlabel('frequency');ylabel('magnitude');title(' spectrum of x(t) (input)');%axis([-.5 .5 -50 50]);
subplot(2,1,2);plot(-0.5:1/1024:.5-1/1024,fy);xlabel('frequency');ylabel('magnitude');title(' spectrum of y(t) (output)');%axis([-.5 .5 -50 50]);
pause;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -