from
Fixed-point signal processing in M
by Tom Bryan
Functions accompanying MATLAB News & Notes article "Fixed-point Signal Processing: Getting Started"
|
| fir_filter(b,x,y) |
function y = fir_filter(b,x,y)
%FIR_FILTER Finite Impulse Response Filter
% Y = FIR_FILTER(B,X,Y) filters the data in vector X with the finite
% impulse response (FIR) filter described by vector B to create the
% filtered data Y. The filter implements the moving average:
%
% y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)
%
% where nb = length(b)-1.
%
% The output vector Y is used as an input to this function so that it
% will be aware of its data type.
% This M-code was used to produce the plots in the News and Notes article
% Fixed-point Signal Processing: Getting Started, by Darel A. Linebarger
% and Thomas A. Bryan, 2004.
z = zeros(length(b),1);
for k=1:length(x)
z = [x(k); z(1:end-1)];
y(k) = b*z; % Inner product
end
|
|
Contact us at files@mathworks.com