createAndSetCImplementationReturn
Create implementation return argument from specified properties and add to implementation for code replacement table entry
Description
creates an implementation return argument from specified properties and adds the
argument to the implementation for a code replacement table.arg
= createAndSetCImplementationReturn(hEntry
,argType
,Name=Name
,varargin
)
Implementation return arguments must describe fundamental numeric data types, such
as double
, single
, int32
,
int16
, int8
, uint32
,
uint16
, uint8
, or
boolean
(not fixed-point data types).
Examples
Specify Operator Output and Input Arguments
This example shows how to use the
createAndSetCImplementationReturn
function with the
createAndAddImplementationArg
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 );
Specify Types for Operator Implementation
These examples show some common type specifications using
createAndSetCImplementationReturn
.
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' );
Specify Type Properties for Operator Implementation
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' );
Specify a Matrix Argument
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 type
uint8
.
hEntry = RTW.TflCOperationEntry; % . % . % . createAndSetCImplementationReturn(hEntry, 'RTW.TflArgMatrix', ... 'Name', 'mat_out1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'DimRange', [2 1; Inf Inf], ... 'BaseType', 'uint8');
Input Arguments
hEntry
— Handle to a code replacement table entry
handle
The hEntry
is a handle to a code replacement
table entry previously returned by instantiating a code replacement entry
class, such as
or
hEntry
=
RTW.TflCFunctionEntry
.hEntry
=
RTW.TflCOperationEntry
Example: op_entry
argType
— Specifies the argument type to create
'RTW.TflArgNumeric'
| character vector | string scalar
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
— Name of the argument to create
character vector | string scalar
Name of the argument to create, specified as a character vector or string scalar.
Example: 'Name','y1'
Example: 'Name','argOut'
varargin
— Name-value pairs that specify the implementation return argument
name-value pairs
Example: 'IOType','RTW_IO_OUTPUT'
Name-Value Arguments
Specify optional pairs of arguments as
Name1=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'
IOType
— Specifies the I/O type of the argument
'RTW_IO_OUTPUT'
| character vector | string scalar
Use 'RTW_IO_OUTPUT'
for output.
Example: 'IOType','RTW_IO_OUTPUT'
Type
— Data type of the argument
character vector | string scalar
Data type of the argument, specified as a character vector or string
scalar. You can specify built-in MATLAB data types such as
uint8
, 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 the
Type
, 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)'
IsSigned
— Indicates whether the argument is signed
true
(default) | false
Boolean value that, when set to true
, indicates
that the argument is signed. The default is
true
.
Example: 'IsSigned',true
WordLength
— Specifies the word length, in bits, of the argument
16
(default) | integer
Example: 'WordLength',16
DataTypeMode
— Specifies the data type mode of the argument
'Fixed-point: binary point
scaling'
(default) | 'Fixed-point: slope and bias scaling'
| 'boolean'
| 'double'
| 'single'
You can specify either DataType
(with
Scaling
) or DataTypeMode
, but
do not specify both.
Example: 'DataTypeMode','Fixed-point: binary point
scaling'
DataType
— Specifies the data type of the argument
'Fixed'
(default) | 'boolean'
| 'double'
| 'single'
Example: 'DataType','Fixed'
Scaling
— Specifies the data type scaling of the argument
'BinaryPoint'
(default) | 'SlopeBias'
Use 'BinaryPoint'
for binary-point scaling or
'SlopeBias'
for slope and bias scaling.
Example: 'Scaling','BinaryPoint'
Slope
— Specifies the slope for a fixed-point argument
1.0
(default) | floating-point value
You can optionally specify either this parameter or a combination of
the SlopeAdjustmentFactor
and
FixedExponent
parameters, but do not specify
both.
Example: 'Slope',1.0
SlopeAdjustmentFactor
— Specifies the slope adjustment factor (F
) part of the slope,
F
2E
,
of the argument
1.0
(default) | floating-point value
F
2E
You can optionally specify either the Slope
parameter or a combination of this parameter and the
FixedExponent
parameter, but do not specify
both.
Example: 'SlopeAdjustmentFactor',1.0
FixedExponent
— Specifies the fixed exponent (E
) part of the slope, F
2E
,
of the argument
-15
(default) | integer value
F
2E
You can optionally specify either the Slope
parameter or a combination of this parameter and the
SlopeAdjustmentFactor
parameter, but do not
specify both.
Example: 'FixedExponent',0
Bias
— Specifies the bias of the argument
0.0
(default) | floating-point value
Example: 'Bias',0.0
FractionLength
— Specifies the fraction length of the argument
15
(default) | integer value
Example: 'FractionLength',0
Output Arguments
arg
— Handle to the created implementation return argument
handle
Specifying the return argument in the
createAndSetCImplementationReturn
function call is
optional.
Version History
Introduced in R2007bR2023b: Specify pre-defined data types by using the Type
argument
You can now specify pre-defined data types for the argument by using the
Type
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 as
IsSigned
or WordLength
.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)