createAndSetCImplementationReturn - Create implementation return argument from specified properties and add to
implementation for code replacement table entry - MATLAB ([original](https://www.mathworks.com/help/ecoder/ref/createandsetcimplementationreturn.html)) ([raw](?raw))
Create implementation return argument from specified properties and add to implementation for code replacement table entry
Syntax
Description
[arg](#d126e21645) = createAndSetCImplementationReturn([hEntry](#d126e21154),[argType](#d126e21185),Name=[Name](#mw%5F7f4c6fb9-31cd-4c51-9259-12c8340f11bd),[varargin](#d126e21240))
creates an implementation return argument from specified properties and adds the argument to the implementation for a code replacement table.
Implementation return arguments must describe fundamental numeric data types, such as double
, single
, int32
,int16
, int8
, uint32
,uint16
, uint8
, orboolean
(not fixed-point data types).
Examples
This example shows how to use thecreateAndSetCImplementationReturn
function with thecreateAndAddImplementationArg
function to specify the output and input arguments for an operator implementation.
op_entry = RTW.TflCOperationEntry; . . . createAndSetCImplementationReturn(op_entry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'IsSigned', true, ... 'WordLength', 32, ... 'FractionLength', 0);
createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT',... 'IsSigned', true,... 'WordLength', 32, ... 'FractionLength', 0 );
createAndAddImplementationArg(op_entry, 'RTW.TflArgNumeric',... 'Name', 'u2', ... 'IOType', 'RTW_IO_INPUT',... 'IsSigned', true,... 'WordLength', 32, ... 'FractionLength', 0 );
These examples show some common type specifications usingcreateAndSetCImplementationReturn
.
hEntry = RTW.TflCOperationEntry; . . . % uint8: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'Type', 'uint8' );
% single: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'Type', 'single' );
% double: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'Type', 'double' );
% boolean: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'Type', 'boolean' );
% complex: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'Type', 'cint16' );
These examples show how to specify types by using several properties of the data type.
hEntry = RTW.TflCOperationEntry; . . . % uint8: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'IsSigned', false, ... 'WordLength', 8, ... 'FractionLength', 0 );
% single: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'DataTypeMode', 'single' );
% double: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'DataTypeMode', 'double' );
% boolean: createAndSetCImplementationReturn(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'DataTypeMode', 'boolean' );
This example shows how to create a return argument that is a two-dimensional matrix of size 2-by-1 or larger and has base typeuint8
.
hEntry = RTW.TflCOperationEntry; % . % . % . createAndSetCImplementationReturn(hEntry, 'RTW.TflArgMatrix', ... 'Name', 'mat_out1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'DimRange', [2 1; Inf Inf], ... 'BaseType', 'uint8');
Input Arguments
The hEntry
is a handle to a code replacement table entry previously returned by instantiating a code replacement entry class, such as _`hEntry`_ = RTW.TflCFunctionEntry
or_`hEntry`_ = RTW.TflCOperationEntry
.
Example: op_entry
The argType
is a character vector or string scalar that specifies the argument type to create. Use'RTW.TflArgNumeric'
for numeric.
Example: 'RTW.TflArgNumeric'
Name of the argument to create, specified as a character vector or string scalar.
Example: 'Name','y1'
Example: 'Name','argOut'
Example: 'IOType','RTW_IO_OUTPUT'
Name-Value Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, where Name
is the argument name and Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose Name
in quotes.
Example: 'IOType','RTW_IO_OUTPUT'
Use 'RTW_IO_OUTPUT'
for output.
Example: 'IOType','RTW_IO_OUTPUT'
Data type of the argument, specified as a character vector or string scalar. You can specify built-in MATLAB data types such asuint8
, boolean
,double
, and others. You can also specify data types that you create by using the fixdt
function, such as fixdt(1,16,2)
. When you specify theType
, you do not need to specify other properties of the type, such as the signedness or word length.
Example: 'Type','uint8'
Example: 'Type','fixdt(1,16,2)'
Boolean value that, when set to true
, indicates that the argument is signed. The default istrue
.
Example: 'IsSigned',true
You can specify either DataType
(withScaling
) or DataTypeMode
, but do not specify both.
Example: 'DataTypeMode','Fixed-point: binary point scaling'
Example: 'DataType','Fixed'
Use 'BinaryPoint'
for binary-point scaling or'SlopeBias'
for slope and bias scaling.
Example: 'Scaling','BinaryPoint'
You can optionally specify either this parameter or a combination of the SlopeAdjustmentFactor
andFixedExponent
parameters, but do not specify both.
Example: 'Slope',1.0
You can optionally specify either the Slope
parameter or a combination of this parameter and theFixedExponent
parameter, but do not specify both.
Example: 'SlopeAdjustmentFactor',1.0
You can optionally specify either the Slope
parameter or a combination of this parameter and theSlopeAdjustmentFactor
parameter, but do not specify both.
Example: 'FixedExponent',0
Example: 'FractionLength',0
Output Arguments
Specifying the return argument in thecreateAndSetCImplementationReturn
function call is optional.
Version History
Introduced in R2007b
You can now specify pre-defined data types for the argument by using theType
argument. Specify built-in MATLAB data types or fixed-point data types. When you use the Type
argument, you do not need to specify other properties of the data type such asIsSigned
or WordLength
.