📄 scale_coeffs.m
字号:
%*************************************************************************
% function scale_coeffs(h,num_phases)
% This function scales a set of filter coefficients h so that the filter
% will never overflow. The maximum output of a FIR is the sum of the
% absolute values of the coefficients of any polyphase. That is because
% the "worst case" condition occurs when the input data is -1 for each
% negative coeff and +1 for each positive coeff. This function finds
% the maximum value of the sum of the absolute values of the coeffs of
% any phase and returns the scaled coeffs.
% Arguments:
% h: unscaled coeffs
% num_phases: Number of polyphases. For example, a filter that
% interpolates by three has three polyphases. For
% decimation filters, use num_phases=1.
%
% Kevin Neilson, Xilinx, April 2007
%*************************************************************************
function [ scaled_h gain_h ] = scale_coeffs(h,num_phases);
for k=1:num_phases
max_phase_val = sum(abs(h([k:num_phases:end])));
end
max_val = max(max_phase_val);
scaled_h = h./max_val;
gain_h = 1/max_val;
disp(['Scaling coeffs by ',num2str(gain_h)])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -