Fixed-Point Designer Functions

Fixed-Point Basics

Fixed-Point Basics in MATLAB

 `fi` Construct fixed-point numeric object `ufi` Construct unsigned fixed-point numeric object `sfi` Construct signed fixed-point numeric object `fimath` Set fixed-point math settings `fipref` Set fixed-point preferences `numerictype` Construct numerictype object `accumpos` Add two fi objects or values `accumneg` Subtract two fi objects or values `quantize` Quantize fixed-point numbers `bin` Binary representation of stored integer of fi object `dec` Unsigned decimal representation of stored integer of fi object `double` Double-precision floating-point real-world value of fi object `hex` Hexadecimal representation of stored integer of fi object `removefimath` Remove fimath object from fi object `setfimath` Attach fimath object to fi object `globalfimath` Configure global fimath and return handle object `removeglobalfimathpref` Remove global fimath preference `resetglobalfimath` Set global fimath to MATLAB factory default `storedInteger` Stored integer value of fi object `storedIntegerToDouble` Convert stored integer value of fi object to built-in double value `embedded.fi` Fixed-point numeric object `embedded.fimath` fimath object `embedded.numerictype` numerictype object

Fixed-Point Design for MATLAB Code

Fixed-Point Functions

Math

Array and Matrix Operations
Array Creation and Concatenation
 `diag` Diagonal matrices or diagonals of matrix `eye` Create identity matrix with fixed-point properties `ndgrid` Generate arrays for N-D functions and interpolation `ones` Create array of all ones with fixed-point properties `zeros` Create array of all zeros with fixed-point properties
Array and Matrix Manipulation
 `flip` Flip order of elements `fliplr` Flip matrix left to right `flipud` Flip matrix up to down `horzcat` Horizontally concatenate multiple fi objects `ipermute` Inverse permute dimensions of multidimensional array `permute` Rearrange dimensions of multidimensional array `repmat` Replicate and tile array `reshape` Reshape array `shiftdim` Shift dimensions `sort` Sort elements of real-valued fi object in ascending or descending order `squeeze` Remove singleton dimensions `vertcat` Vertically concatenate multiple fi objects
Basic Array and Matrix Information
 `colon` Create vectors, array subscripting `end` Last index of array `iscolumn` Determine whether fi object is column vector `isempty` Determine whether array is empty `isrow` Determine whether fi object is row vector `isscalar` Determine whether input is scalar `isvector` Determine whether input is vector `length` Vector length `ndims` Number of array dimensions `numel` Number of data elements in fi array `size` Array dimensions `isequal` Determine whether real-world values of two fi objects are equal, or determine whether properties of two fimath, numerictype, or quantizer objects are equal `isequivalent` Determine if two numerictype objects have equivalent properties `isfloat` Determine whether input is floating-point data type `isfinite` Determine whether array elements are finite `isinf` Determine whether array elements are infinite `isnan` Determine whether array elements are NaN `isnumeric` Determine whether input is numeric array `max` Largest element in array of fi objects `min` Smallest element in array of fi objects `disp` Display object `isobject` Determine whether input is MATLAB object `numberofelements` Number of data elements in an array
Array and Matrix Operators
 `buffer` Buffer signal vector into matrix of data frames `colon` Create vectors, array subscripting `ctranspose` Complex conjugate transpose of fi object `minus` Matrix difference between fi objects `mpower` Fixed-point matrix power (^) `mtimes` Matrix product of fi objects `plus` Matrix sum of fi objects `qr` Orthogonal-triangular decomposition `rdivide` Right-array division (./) `shiftdata` Shift data to operate on specified dimension `sum` Sum of array elements `surfnorm` Compute and display 3-D surface normals `times` Element-by-element multiplication of fi objects `transpose` Transpose operation `tril` Lower triangular part of matrix `triu` Upper triangular part of matrix `uminus` Negate elements of fi object array `unshiftdata` Inverse of shiftdata `uplus` Unary plus
Specialized Matrices
 `hankel` Hankel matrix `toeplitz` Create Toeplitz matrix
Sparse Matrices
 `spy` Visualize sparsity pattern `etreeplot` Plot elimination tree `gplot` Plot set of nodes using adjacency matrix `treeplot` Plot picture of tree
Complex Math
 `complex` Construct complex fi object from real and imaginary parts `conj` Complex conjugate of fi object `abs` Absolute value of fi object `imag` Imaginary part of complex number `real` Real part of complex number `sign` Perform signum function on array `isreal` Determine whether array elements are real
Constants
 `eps` Quantized relative accuracy for fi or quantizer objects `intmax` Largest positive stored integer value representable by numerictype of fi object `intmin` Smallest stored integer value representable by numerictype of fi object
CORDIC
 `cordicabs` CORDIC-based absolute value `cordicangle` CORDIC-based phase angle `cordicatan2` CORDIC-based four quadrant inverse tangent `cordiccart2pol` CORDIC-based approximation of Cartesian-to-polar conversion `cordiccexp` CORDIC-based approximation of complex exponential `cordiccos` CORDIC-based approximation of cosine `cordicpol2cart` CORDIC-based approximation of polar-to-Cartesian conversion `cordicrotate` Rotate input using CORDIC-based approximation `cordicsin` CORDIC-based approximation of sine `cordicsincos` CORDIC-based approximation of sine and cosine `cordicsqrt` CORDIC-based approximation of square root `cordictanh` CORDIC-based hyperbolic tangent
Exponentials
 `pow2` Efficient fixed-point multiplication by 2K `power` Fixed-point array power (.^) `sqrt` Square root of fi object
Math Operations
 `accumneg` Subtract two fi objects or values `accumpos` Add two fi objects or values `add` Add two objects using fimath object `atan2` Four-quadrant inverse tangent of fixed-point values `conv` Convolution and polynomial multiplication of fi objects `convergent` Round toward nearest integer with ties rounding to nearest even integer `cos` Cosine of fi object `divide` Divide two objects `filter` One-dimensional digital filter of fi objects `innerprodintbits` Number of integer bits needed for fixed-point inner product `mpy` Multiply two objects using fimath object `mrdivide` Forward slash (/) or right-matrix division `sin` Sine of fixed-point values `sub` Subtract two objects using fimath object
 `bin` Binary representation of stored integer of fi object `bin2num` Convert two's complement binary string to number using quantizer object `dec` Unsigned decimal representation of stored integer of fi object `hex` Hexadecimal representation of stored integer of fi object `num2bin` Convert number to binary representation using quantizer object `num2int` Convert number to signed integer `oct` Octal representation of stored integer of fi object `sdec` Signed decimal representation of stored integer of fi object `num2hex` Convert number to hexadecimal equivalent using quantizer object `hex2num` Convert hexadecimal string to number using quantizer object
Rounding and Remainders
 `ceil ` Round toward positive infinity `fix` Round toward zero `floor` Round toward negative infinity `mod` Modulus after division for fi objects `nearest` Round toward nearest integer with ties rounding toward positive infinity `round` Round fi object toward nearest integer or round input data using quantizer object
Statistics
 `errmean` Mean of quantization error `errpdf` Probability density function of quantization error `errvar` Variance of quantization error `logreport` Quantization report `maxlog` Log maximums `minlog` Log minimums `noperations` Number of operations `noverflows` Number of overflows `nunderflows` Number of underflows `resetlog` Clear log for fi or quantizer object `mean` Average or mean value of fixed-point array `median` Median value of fixed-point array

Simulation Acceleration

 `fiaccel` Accelerate fixed-point code and convert floating-point MATLAB code to fixed-point MATLAB code `coder.allowpcode` Control code generation from protected MATLAB files `coder.const` Fold expressions into constants in generated code `coder.cstructname` Name structure in generated code `coder.extrinsic` Declare extrinsic function or functions `coder.inline` Control inlining in generated code `coder.mexconfig` Code acceleration configuration object `coder.newtype` Create a coder.Type object `coder.nullcopy` Declare uninitialized variables `coder.resize` Resize a coder.Type object `coder.screener` Determine if function is suitable for code generation `coder.target` Determine if code generation target is specified target `coder.typeof` Create coder.Type object to represent the type of an entry-point function input `coder.unroll` Unroll for-loop by making a copy of the loop body for each loop iteration `coder.varsize` Declare variable-size array `coder.ArrayType` Represent set of MATLAB arrays `coder.CellType` Represent set of MATLAB cell arrays `coder.Constant` Represent set containing one MATLAB value `coder.EnumType` Represent set of MATLAB enumerations `coder.FiType` Represent set of MATLAB fixed-point arrays `coder.MexConfig` Code acceleration configuration object for use with fiaccel `coder.PrimitiveType` Represent set of logical, numeric, or char arrays `coder.StructType` Represent set of MATLAB structure arrays `coder.Type` Represent set of MATLAB values

Graphics

3-D Visualization
 `mesh` Create mesh plot `meshc` Create mesh plot with contour plot `meshz` Create mesh plot with curtain plot `surf` Create 3-D shaded surface plot `surfc` Create 3-D shaded surface plot with contour plot `surfl` Create surface plot with colormap-based lighting `trimesh` Create triangular mesh plot `triplot` Create 2-D triangular plot `trisurf` Create triangular surface plot `streamribbon` Create 3-D stream ribbon plot `streamslice` Draw streamlines in slice planes `streamtube` Create 3-D stream tube plot `rgbplot` Plot colormap `coneplot` Plot velocity vectors as cones in 3-D vector field
Basic Plots and Graphs
 `errorbar` Plot error bars along curve `line` Create line object `loglog` Create log-log scale plot `plot` Create linear 2-D plot `plot3` Create 3-D line plot `plotyy` Create graph with y-axes on right and left sides `polar` Plot polar coordinates `semilogx` Create semilogarithmic plot with logarithmic x-axis `semilogy` Create semilogarithmic plot with logarithmic y-axis `xlim` Set or query x-axis limits `ylim` Set or query y-axis limits `zlim` Set or query z-axis limits `clabel` Create contour plot elevation labels `text` Create text object in current axes `copyobj` Make independent copy of quantizer object
Specialized Plots
 `area` Create filled area 2-D plot `bar` Create vertical bar graph `barh` Create horizontal bar graph `contour` Create contour graph of matrix `contour3` Create 3-D contour plot `contourc` Create two-level contour plot computation `contourf` Create filled 2-D contour plot `ezcontour` Easy-to-use contour plotter `ezcontourf` Easy-to-use filled contour plotter `comet` Create 2-D comet plot `comet3` Create 3-D comet plot `feather` Plot velocity vectors `quiver` Create quiver or velocity plot `quiver3` Create 3-D quiver or velocity plot `stairs` Create stairstep graph `stem` Plot discrete sequence data `stem3` Plot 3-D discrete sequence data `ezmesh` Easy-to-use 3-D mesh plotter `ezplot` Easy-to-use function plotter `ezplot3` Easy-to-use 3-D parametric curve plotter `ezpolar` Easy-to-use polar coordinate plotter `ezsurf` Easy-to-use 3-D colored surface plotter `ezsurfc` Easy-to-use combination surface/contour plotter `fplot` Plot function between specified limits `hist` Create histogram plot `histc` Histogram count `rose` Create angle histogram `plotmatrix` Draw scatter plots `scatter` Create scatter or bubble plot `scatter3` Create 3-D scatter or bubble plot `pcolor` Create pseudocolor plot `ribbon` Create ribbon plot `slice` Create volumetric slice plot `waterfall` Create waterfall plot `voronoi` Create Voronoi diagram `voronoin` Create n-D Voronoi diagram `compass` Plot arrows emanating from origin `patch` Create patch graphics object

Relational Operators

 `eq` Determine whether real-world values of two fi objects are equal `ge` Determine whether real-world value of one fi object is greater than or equal to another `gt` Determine whether real-world value of one fi object is greater than another `le` Determine whether real-world value of fi object is less than or equal to another `lt` Determine whether real-world value of one fi object is less than another `ne` Determine whether real-world values of two fi objects are not equal

Programming and Data Types

Object-Oriented Programming
 `fi` Construct fixed-point numeric object `fipref` Set fixed-point preferences `savefipref` Save fi preferences for next MATLAB session `fimath` Set fixed-point math settings `numerictype` Construct numerictype object `quantizer` Construct quantizer object `assignmentquantizer` Assignment quantizer object of fi object `mat2str` Convert matrix to string `get` Property values of object `subsasgn` Subscripted assignment `subsref` Subscripted reference `removefimath` Remove fimath object from fi object `reset` Reset objects to initial conditions `set` Set or display property values for quantizer objects `setfimath` Attach fimath object to fi object `sfi` Construct signed fixed-point numeric object `tostring` Convert numerictype or quantizer object to string `ufi` Construct unsigned fixed-point numeric object `unitquantizer` Constructor for unitquantizer object `fixed.aggregateType` Compute aggregate numerictype
Data Type Operators and Tools
 `storedInteger` Stored integer value of fi object `storedIntegerToDouble` Convert stored integer value of fi object to built-in double value `reinterpretcast` Convert fixed-point data types without changing underlying data `rescale` Change scaling of fi object `stripscaling` Stored integer of fi object `buildInstrumentedMex` Generate compiled C code function including logging instrumentation `clearInstrumentationResults` Clear results logged by instrumented, compiled C code function `NumericTypeScope` Determine fixed-point data type `showInstrumentationResults` Results logged by instrumented, compiled C code function `double` Double-precision floating-point real-world value of fi object `int16` Convert fi object to signed 16-bit integer `int32` Convert fi object to signed 32-bit integer `int64` Convert fi object to signed 64-bit integer `int8` Convert fi object to signed 8-bit integer `single` Single-precision floating-point real-world value of fi object `uint16` Convert fi object to unsigned 16-bit integer `uint32` Stored integer value of fi object as built-in uint32 `uint64` Convert fi object to unsigned 64-bit integer `uint8` Convert fi object to unsigned 8-bit integer `logical` Convert numeric values to logical `realmax` Largest positive fixed-point value or quantized number `realmin` Smallest positive normalized fixed-point value or quantized number
Bitwise Operations
 `bitand` Bitwise AND of two fi objects `bitor` Bitwise OR of two fi objects `bitxor` Bitwise exclusive OR of two fi objects `bitandreduce` Reduce consecutive slice of bits to one bit by performing bitwise AND operation `bitorreduce` Reduce consecutive slice of bits to one bit by performing bitwise OR operation `bitxorreduce` Reduce consecutive slice of bits to one bit by performing bitwise exclusive OR operation `bitror` Bitwise rotate right `bitshift` Shift bits specified number of places `bitrol` Bitwise rotate left `bitsll` Bit shift left logical `bitsra` Bit shift right arithmetic `bitsrl` Bit shift right logical `bitcmp` Bitwise complement of fi object `bitconcat` Concatenate bits of fi objects `bitreplicate` Replicate and concatenate bits of fi object `bitget` Get bits at certain positions `bitset` Set bits at certain positions `bitsliceget` Get consecutive slice of bits `getlsb` Least significant bit `getmsb` Most significant bit
Logical Operations
 `all` Determine whether all array elements are nonzero `and` Find logical AND of array or scalar inputs `any` Determine whether any array elements are nonzero `not` Find logical NOT of array or scalar input `or` Find logical OR of array or scalar inputs `xor` Logical exclusive-OR

Data Analysis

 `denormalmax` Largest denormalized quantized number for quantizer object `denormalmin` Smallest denormalized quantized number for quantizer object `fractionlength` Fraction length of quantizer object `lowerbound` Lower bound of range of fi object `lsb` Scaling of least significant bit of fi object, or value of least significant bit of quantizer object `range` Numerical range of fi or quantizer object `upperbound` Upper bound of range of fi object `wordlength` Word length of quantizer object `sort` Sort elements of real-valued fi object in ascending or descending order `exponentbias` Exponent bias for quantizer object `exponentlength` Exponent length of quantizer object `exponentmax` Maximum exponent for quantizer object `exponentmin` Minimum exponent for quantizer object `isboolean` Determine whether input is Boolean `isdouble` Determine whether input is double-precision data type `isfi` Determine whether variable is fi object `isfimath` Determine whether variable is fimath object `isfimathlocal` Determine whether fi object has local fimath `isfipref` Determine whether input is fipref object `isfixed` Determine whether input is fixed-point data type `isnumerictype` Determine whether input is numerictype object `ispropequal` Determine whether properties of two fi objects are equal `isquantizer` Determine whether input is quantizer object `isscaleddouble` Determine whether input is scaled double data type `isscaledtype` Determine whether input is fixed-point or scaled double data type `isscalingbinarypoint` Determine whether input has binary point scaling `isscalingslopebias` Determine whether input has nontrivial slope and bias scaling `isscalingunspecified` Determine whether input has unspecified scaling `issigned` Determine whether fi object is signed `issingle` Determine whether input is single-precision data type `isslopebiasscaled` Determine whether numerictype object has nontrivial slope and bias

Data Quantizing

 `cast` Cast variable to different data type `quantize` Quantize fixed-point numbers `fixed.Quantizer` Quantize fixed-point numbers `quantizer` Construct quantizer object `quantize method` Apply quantizer object to data `randquant` Generate uniformly distributed, quantized random number using quantizer object `unitquantize` Quantize except numbers within eps of +1 `unitquantizer` Constructor for unitquantizer object

Algorithm Implementation

 `bitand` Bitwise AND of two fi objects `bitor` Bitwise OR of two fi objects `bitshift` Shift bits specified number of places `cordicabs` CORDIC-based absolute value `cordicangle` CORDIC-based phase angle `cordicatan2` CORDIC-based four quadrant inverse tangent `cordiccart2pol` CORDIC-based approximation of Cartesian-to-polar conversion `cordiccexp` CORDIC-based approximation of complex exponential `cordiccos` CORDIC-based approximation of cosine `cordicpol2cart` CORDIC-based approximation of polar-to-Cartesian conversion `cordicrotate` Rotate input using CORDIC-based approximation `cordicsin` CORDIC-based approximation of sine `cordicsincos` CORDIC-based approximation of sine and cosine `cordicsqrt` CORDIC-based approximation of square root `fi` Construct fixed-point numeric object `filter` One-dimensional digital filter of fi objects `for` Execute statements specified number of times `mean` Average or mean value of fixed-point array `median` Median value of fixed-point array `sqrt` Square root of fi object

Algorithm Acceleration

Algorithm Design for Acceleration

Data Definition
Variable-Size Data
 `coder.varsize` Declare variable-size array
Cell Arrays
 `coder.varsize` Declare variable-size array `coder.cstructname` Name structure in generated code `coder.CellType` Represent set of MATLAB cell arrays
MATLAB Classes
 `coder.ClassType` Represent set of MATLAB classes
Function Definition
 `coder.extrinsic` Declare extrinsic function or functions `coder.ignoreConst` Prevent use of constant value of expression for function specializations `coder.unroll` Unroll for-loop by making a copy of the loop body for each loop iteration

Accelerated Algorithm Generation

Input Specification
 `coder.typeof` Create coder.Type object to represent the type of an entry-point function input `coder.resize` Resize a coder.Type object `coder.newtype` Create a coder.Type object `coder.varsize` Declare variable-size array `coder.ArrayType` Represent set of MATLAB arrays `coder.CellType` Represent set of MATLAB cell arrays `coder.ClassType` Represent set of MATLAB classes `coder.Constant` Represent set containing one MATLAB value `coder.EnumType` Represent set of MATLAB enumerations `coder.FiType` Represent set of MATLAB fixed-point arrays `coder.PrimitiveType` Represent set of logical, numeric, or char arrays `coder.StructType` Represent set of MATLAB structure arrays `coder.Type` Represent set of MATLAB values
Build Configuration
 `coder.mexconfig` Code acceleration configuration object `fiaccel` Accelerate fixed-point code and convert floating-point MATLAB code to fixed-point MATLAB code `coder.MexConfig` Code acceleration configuration object for use with fiaccel
Creation of Accelerated Executable
 `fiaccel` Accelerate fixed-point code and convert floating-point MATLAB code to fixed-point MATLAB code `coder.allowpcode` Control code generation from protected MATLAB files `coder.const` Fold expressions into constants in generated code `coder.cstructname` Name structure in generated code `coder.extrinsic` Declare extrinsic function or functions `coder.inline` Control inlining in generated code `coder.load` Load compile-time constants from MAT-file or ASCII file into caller workspace `coder.newtype` Create a coder.Type object `coder.nullcopy` Declare uninitialized variables `coder.resize` Resize a coder.Type object `coder.target` Determine if code generation target is specified target `coder.typeof` Create coder.Type object to represent the type of an entry-point function input `coder.unroll` Unroll for-loop by making a copy of the loop body for each loop iteration `coder.varsize` Declare variable-size array `coder.mexconfig` Code acceleration configuration object `coder.ArrayType` Represent set of MATLAB arrays `coder.Constant` Represent set containing one MATLAB value `coder.EnumType` Represent set of MATLAB enumerations `coder.FiType` Represent set of MATLAB fixed-point arrays `coder.PrimitiveType` Represent set of logical, numeric, or char arrays `coder.StructType` Represent set of MATLAB structure arrays `coder.Type` Represent set of MATLAB values `coder.MexConfig` Code acceleration configuration object for use with fiaccel
Code Analysis
 `coder.screener` Determine if function is suitable for code generation

Algorithm Conversion

Automated Conversion

 `fiaccel` Accelerate fixed-point code and convert floating-point MATLAB code to fixed-point MATLAB code `coder.config` Create configuration object for fixed-point or single-precision conversion `coder.mexconfig` Code acceleration configuration object `coder.approximation` Create function replacement configuration object `coder.allowpcode` Control code generation from protected MATLAB files `coder.const` Fold expressions into constants in generated code `coder.extrinsic` Declare extrinsic function or functions `coder.inline` Control inlining in generated code `coder.load` Load compile-time constants from MAT-file or ASCII file into caller workspace `coder.newtype` Create a coder.Type object `coder.nullcopy` Declare uninitialized variables `coder.resize` Resize a coder.Type object `coder.target` Determine if code generation target is specified target `coder.typeof` Create coder.Type object to represent the type of an entry-point function input `coder.unroll` Unroll for-loop by making a copy of the loop body for each loop iteration `coder.varsize` Declare variable-size array `coder.MexConfig` Code acceleration configuration object for use with fiaccel `coder.FixptConfig` Floating-point to fixed-point conversion configuration object `coder.ArrayType` Represent set of MATLAB arrays `coder.Constant` Represent set containing one MATLAB value `coder.EnumType` Represent set of MATLAB enumerations `coder.FiType` Represent set of MATLAB fixed-point arrays `coder.PrimitiveType` Represent set of logical, numeric, or char arrays `coder.StructType` Represent set of MATLAB structure arrays `coder.Type` Represent set of MATLAB values

Manual Conversion

 `buildInstrumentedMex` Generate compiled C code function including logging instrumentation `showInstrumentationResults` Results logged by instrumented, compiled C code function `clearInstrumentationResults` Clear results logged by instrumented, compiled C code function `fi` Construct fixed-point numeric object `fimath` Set fixed-point math settings `numerictype` Construct numerictype object `zeros` Create array of all zeros with fixed-point properties `ones` Create array of all ones with fixed-point properties `cast` Cast variable to different data type

Convert to Fixed Point

Prepare System for Conversion

 `DataTypeWorkflow.Converter` Create fixed-point converter object

Collect Ranges

 `DataTypeWorkflow.Converter` Create fixed-point converter object

Convert to Fixed Point

 `nts` Determine fixed-point data type `DataTypeWorkflow.Converter` Create fixed-point converter object `DataTypeWorkflow.ProposalSettings` Proposal settings object for data type proposals

Verify Fixed-Point Conversion

 `DataTypeWorkflow.Converter` Create fixed-point converter object `DataTypeWorkflow.Result` Object containing run result information `DataTypeWorkflow.DiffRunResult` Results from comparing two simulation runs `DataTypeWorkflow.DiffSignalResult` Results from comparing two signals

Single-Precision Design for MATLAB Code

 `convertToSingle` Convert double-precision MATLAB code to single-precision MATLAB code `coder.config` Create configuration object for fixed-point or single-precision conversion `coder.SingleConfig` Double-precision to single-precision conversion configuration object

 `DataTypeWorkflow.Single.convertToSingle` Convert a double-precision system to single precision