⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 f_getas.m

📁 DSP程序 Matlab是一套用于科学工程计算的可视化高性能语言与软件环境。它集数值分析、矩阵运算、信号处理和图形显示于一体
💻 M
字号:
function [As,f] = f_getAs (b,a,fs,eps)

%_GETAS: Estimate stopband attenuation in dB of a lowpass filter
%
% Usage: [As,f] = f_getAs (b,a,fs,eps)
%
% Inputs: 
%         b   = 1 by m+1 array containing the numerator coefficients
%         a   = 1 by n+1 array containing the denominator coefficients
%         fs  = sampling frequency
%         eps = threshold used for determining the first zero in dB
% Outputs: 
%          As = the stopband attenuation in dB:
%
%               As = -20log10(delta_s)
%
%          f  = frequency at which maximum stopband attenuation 
%                   occurs 
%
% Notes: This function only works with a lowpass filter with zeros
%        on the unit circle.  

% Initialize

N = 1000;

% Compute magnitude response

[H,f] = f_freqz(b,a,N,fs);
A = 20*log10(abs(H));

% Estimate As

k = 0;
for i = 1 : N
   if A(i) < -eps
      k = i;
      break
   end
end
if k > 0
   [ripple,kmax] = max(A(k:N));
   As = -ripple;
   f = (k+kmax-1)*(fs/2)/N;
else
   As = 0;
   f = 0;
end

⌨️ 快捷键说明

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