samp7_3.m

来自「用matlab编程绘制矩形窗函数的幅频特性」· M 代码 · 共 24 行

M
24
字号
%Samp7_3
clf;Nf=512;
for ii=1:4
   switch ii
   case 1
      Nwin=10;   
   case 2
      Nwin=20;
   case 3
      Nwin=50;
   case 4      
      Nwin=100;
   end
   w=boxcar(Nwin);                %矩形窗
   [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');
   stext=['N=' int2str(Nwin)];               %给出标题,指出所用的数据个数
   title(stext);grid on;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?