scale_coeffs.m
来自「This is GMS down upper converter and dow」· M 代码 · 共 26 行
M
26 行
%*************************************************************************
% 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 + =
减小字号Ctrl + -
显示快捷键?