?? samp7_2.m
字號:
%Samp7_2
clf;Nf=512; %窗函數復數頻率特性的數據點數
Nwin=20; %窗函數數據長度
figure(1)
for ii=1:4
switch ii
case 1
w=boxcar(Nwin); %矩形窗
stext='矩形窗';
case 2
w=hanning(Nwin); %漢寧窗
stext='漢寧窗';
case 3
w=hamming (Nwin); %哈明窗
stext='哈明窗';
case 4
w=bartlett(Nwin); % Bartlett窗
stext='Bartelett窗';
end
[y,f]=freqz(w,1,Nf); %求解窗函數的幅頻特性,窗函數相當于一個數字濾波器
mag=abs(y);%求得窗函數幅頻特性
posplot=['2,2,' int2str(ii)];
subplot(posplot);
plot(f/pi,20* log10(mag/max(mag))); %繪制窗函數的幅頻特性
xlabel('歸一化頻率');ylabel('振幅/dB');
title(stext);grid on;
end
figure(2)
for ii=1:4
switch ii
case 1
w=blackman(Nwin); %Blackman 窗
stext='Blackman窗';
case 2
w=triang(Nwin); %三角窗
stext='三角窗';
case 3
w=kaiser(Nwin,4); %Kaiser窗
stext='Kaiser窗(Beta=4)';
case 4
w=chebwin(Nwin,40); %Chebyshev 窗
stext='Chebyshev窗(r=40)';
end
[y,f]=freqz(w,1,Nf); %以 Nf點數求解窗函數的幅頻響應
mag=abs(y); %求得窗函數幅頻響應
posplot=['2,2,' int2str(ii)];
subplot(posplot);plot(f/pi,20* log10(mag/max(mag))); %繪制幅頻響應
xlabel('歸一化頻率');ylabel('振幅/dB');
title(stext);grid on;
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -