📄 calc_transfer.m
字号:
%% calc_transfer.m
%%
% This function calculates the transfer function of the combined equalizer.
% the function returns a vector containing the phase of the equalizer, and
% another vector containing the magnitude of the equalizer. |w0_vector|
% provides a vector to plot the phase or magnitude against. The
% frequencies in this vector are logarithmically spaced.
function [filter_mag,filter_phase,w0_vector] = calc_transfer(w0,q0,hbp,n)
%%
%% Vector Initialization
%%
% The w0_vector (the x axis in a bode plot) is created based on the
% maximum and minimum center frequencies of the equalizer. Also, the
% vector which will hold the complex transfer function of the equalizer is
% intialized
w0_vector = logspace(log10(w0(1)*.01),log10(w0(n)*100),1000);
filter_vector = zeros(1,1000);
%%
%% Transfer Function Calculations
%%
% For each filter in the equalizer, the parameters of the filter are
% extracted from the input, and the second order transfer function is calculated. These
% individual transfer functions are added, since each filter would be
% connected in parallel.
for filter_n = 1:n
%calculate the filter parameters...
w0f = w0(filter_n);
hbpf = hbp(filter_n);
q0f = q0(filter_n);
%calculate the filter function...
current_filter_func = (-hbpf * (w0f/q0f)*j.*w0_vector)./((j.*w0_vector).^2 + ((w0f/q0f)*j.*w0_vector) + (w0f^2));
%adding the filters in parallel...
filter_vector = filter_vector + current_filter_func;
end
%%
%% Returned Values
%%
% the magnitude and phase of the combined equalizer are returned. the x
% axis vector has already been created.
%returns
filter_mag = abs(filter_vector);
filter_phase = angle(filter_vector);
%%
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -