Documentation Center    • Trial Software   • Product Updates
Generate Fixed-Point FIR Code Using MATLAB Function Block
Program the MATLAB Function Block  The following example shows
how to create a fixed-point, lowpass, direct form FIR filter in
Simulink®. To create the FIR filter, you use Fixed-Point
Designer™ software and the MATLAB Function block. In this
example, you perform the following tasks in the sequence shown:
1. Place a MATLAB Function block in a new model. You can find
the block in the Simulink User-Defined Functions library.    2.
Save your model as cgen_fi.    3. Double-click the MATLAB
Function block in your model to open the MATLAB Function Block
Editor. Type or copy and paste the following MATLAB® code,
including comments, into the Editor:      function [yout,zf] =
dffirdemo(b, x, zi) %#codegen     %codegen_fi doc model example
%Initialize the output signal yout and the final conditions zf
Ty = numerictype(1,12,8);     yout =
fi(zeros(size(x)),'numerictype',Ty);     zf = zi;