How can I assign fixed-point data types to input and output ports in Level-2 MATLAB file S-functions?
4 views (last 30 days)
Show older comments
I would like to set the data type for my S-function I/O ports to fixed point data types. I know this requires a call to the DataTypeID method but I do not know the ID number for my custom fixed-point data type.
Accepted Answer
MathWorks Support Team
on 29 Jun 2009
This enhancement has been incorporated in Simulink 7.3 (2009a). There is now a demo that illustrates how to work with fixed point Level-2 MATLAB File S-functions. It is located at
$MATLABROOT\toolbox\simulink\blocks\msfcn_complex_multip_fi.m
where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB Command Prompt.
You can also navigate to this model by typing
sfundemos-> MATLAB file S Functions -> Level 2 MATLAB file S Functions -> Fixed Point Multiplication.
For previous product releases, read below for any possible workarounds:
It is possible to register custom fixed-point data type in the Level-2 MATLAB file S-Function as follows:
% Register fixed point datatype to obtain datatype id
isSigned = 1;
wordLength = 16;
fracSlope = 1;
fixedExp = -9;
bias = 0;
obeyDataTypeOverride = false;
dtID = block.RegisterDataTypeFxpFSlopeFixExpBias(isSigned, wordLength, fracSlope, fixedExp, bias, obeyDataTypeOverride);
block.InputPort(1).DatatypeID = dtID;
The above MATLAB code is valid for OutputPort and DWork vector data type definitions.
0 Comments
More Answers (0)
See Also
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!