📄 gain_f.m
字号:
function H=gain_f(b,a,freq)
% H=gain_f(b,a,freq)
%
% H =row vector with N values of complex gain of a linear
% digital system, where N =length of freq vector.
%
% b =numerator weights of linear system transfer function.
% a =denominator weights. a(1) must not be 0. Usually, a(1)=1.
%
% b and a can be arrays. If so, each row contains the weights of a
% section of the digital transfer function in cascade form.
%
% freq =frequency (N=1) or vector of N frequencies.
%
% See also gain, power_gain, pds
% Check the dimensions of b and a. If a=scalar, make b a row.
% See also gain, power_gain, pds
[nra,nca]=size(a);
[nr,ncb]=size(b);
if(nra==1 & nca==1)
b=row_vec(b);
ncb=length(b); nr=1;
elseif nr~=nra,
error('Number of rows in b and a must be the same.')
end
% Inintialize: nb,na = rows, f = row freq. vector.
H=1;
nb=[0:ncb-1];
na=[0:nca-1];
f=row_vec(freq);
% Compute the cascade gain.
Eb=exp(-2*pi*j*(nb'*f));
Ea=exp(-2*pi*j*(na'*f));
for section=1:nr,
B=b(section,:)*Eb;
A=a(section,:)*Ea;
if(min(abs(A))==0),
error('Gain is infinite at some point.');
end
H=H.*B./A;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -