createAndAddImplementationArg
Create implementation argument from specified properties and add to implementation arguments for code replacement table entry
Description
creates an implementation argument from specified properties and adds the argument
to the implementation arguments for a code replacement table entry.arg
= createAndAddImplementationArg(hEntry
,argType
,Name=Name
,varargin
)
Implementation arguments must describe fundamental numeric data types, such as
double
, single
, int32
,
int16
, int8
, uint32
,
uint16
, uint8
, boolean
,
or 'logical'
(not fixed-point data types).
Examples
Specify Implementation Output and Input Arguments
This example shows how to use
thecreateAndAddImplementationArg
function with the
createAndSetCImplementationReturn
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 Implementation Argument
These examples show some common type specifications using
createAndAddImplementationArg
.
hEntry = RTW.TflCOperationEntry; % . % . % . % uint8: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'uint8'); % single: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'single' ); % double: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'double' ); % boolean: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'boolean' ); % complex: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'cint16' ); % matrix of complex integers: createAndAddImplementationArg(hEntry, 'RTW.TflArgMatrix', ... 'Name', 'mat_in1', ... 'IOType', 'RTW_IO_INPUT', ... 'BaseType', 'cint8', ... 'DimRange', [2 1; Inf Inf]);
Specify Type Properties for Implementation Argument
These examples show how to specify types by using several properties of the data type.
hEntry = RTW.TflCOperationEntry; % . % . % . % uint8: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'IsSigned', false, ... 'WordLength', 8, ... 'FractionLength', 0 ); % single: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'single' ); % double: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'double' ); % boolean: createAndAddImplementationArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'boolean' );
Specify a Numeric Constant Argument
This example shows how to add an input argument that is a numeric constant to the implementation function. The actual value of the constant is set during code generation.
hEntry = RTW.TflCOperationEntry; % . % . % . createAndAddImplementationArg(hEntry, 'RTW.TflArgNumericConstant', ... 'Name', 'fl_in1', ... 'IOType', 'RTW_IO_INPUT', ... 'IsSigned', false, ... 'WordLength', 32, ... 'FractionLength', 0, ... 'Value', 0);
Specify a Matrix Argument
This example shows how to create an input argument that is a
two-dimensional matrix of size 2-by-1 or larger and has base type
uint8
.
hEntry = RTW.TflCOperationEntry; % . % . % . createAndAddImplementationArg(hEntry, 'RTW.TflArgMatrix', ... 'Name', 'mat_in1', ... 'IOType', 'RTW_IO_INPUT', ... 'DimRange', [2 1; Inf Inf], ... 'BaseType', 'uint8');
Specify a Structure Argument
This example shows how to create an implementation argument
that is a structure with elements bus1
and
bus2
.
hEnt = RTW.TflEntry; myStruct.Identifier = 'myBus'; elem1.Identifier = 'bus1'; elem1.Type= 'int32'; elem2.Identifier = 'bus2'; elem2.Type = 'double'; myStruct.Elements = [elem1, elem2]; hEnt.createAndAddImplementationArg('RTW.TflArgStruct','Name','u1','StructData',myStruct);
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
character vector | string scalar
Argument type to create, specified as a character vector or string scalar. Specify one of these types of arguments.
'RTW.TflArgNumeric'
— numeric argument'RTW.TflArgNumericConstant'
— numeric constant argument'RTW.TflArgMatrix'
— matrix argument'RTW.TflArgComplex'
— complex argument'RTW.TflArgChar'
— character argument'RTW.TflArgVoid'
— void argument'RTW.TflArgStruct'
— structure argument
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. You may specify:
'u1'
,'u2'
, or follow the format'un'
for input arguments'y1'
,'y2'
, or follow the format'yn'
for output argumentsOther character vector or string scalar names for input or output arguments
Example: 'Name','y1'
Example: 'Name','u1'
varargin
— Name-value pairs that specify the implementation argument
name-value pairs
Example: 'IOType','RTW_IO_INPUT'
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_INPUT'
IOType
— Specifies the I/O type of the argument
'RTW_IO_INPUT'
| character vector | string scalar
Use 'RTW_IO_INPUT'
for input.
Example: 'IOType','RTW_IO_INPUT'
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.
Example: 'IsSigned',true
WordLength
— Specifies the word length, in bits, of the argument
16
(default) | integer value
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 of the 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
Value
— Specifies the initial value of the argument
0
(default) | constant value
Use this parameter only to set the value of injected constant input
arguments, such as arguments that pass fraction-length
values or flag values, in an implementation function
signature. Do not use it for standard generated input
arguments, such as
u1
u2
. You can
supply a constant input argument that uses this parameter
anywhere in the implementation function signature, except
as the return argument.
You can inject constant input arguments into the implementation signature for code replacement table entries. If the argument values or the number of arguments required depends on compile-time information, you can use custom matching. For more information, see Customize Match and Replacement Process.
Example: 'Value',0
StructElements
— Elements of structure argument
structure
Elements of the structure for a structure argument, specified as a structure in which each field identifies an element of the structure.
Example: 'StructElements',elements
Output Arguments
arg
— Handle to the created implementation argument
handle
Specifying the return argument in the
createAndAddImplementationArg
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
.
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
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)