createAndAddConceptualArg
Create conceptual argument from specified properties and add to conceptual arguments for code replacement table entry
Description
Examples
Specify Conceptual Output and Input Arguments
This example shows how to use
thecreateAndAddConceptualArg
function to specify
conceptual output and input arguments for a code replacement operator
entry.
For examples of fixed-point arguments that use relative scaling or relative slope/bias values, see Net Slope Scaling Code Replacement and Equal Slope and Zero Net Bias Code Replacement.
op_entry = RTW.TflCOperationEntry; % . % . % . createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'IsSigned', true, ... 'WordLength', 32, ... 'FractionLength', 0); createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric',... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT',... 'IsSigned', true,... 'WordLength', 32, ... 'FractionLength', 0 ); createAndAddConceptualArg(op_entry, 'RTW.TflArgNumeric',... 'Name', 'u2', ... 'IOType', 'RTW_IO_INPUT',... 'IsSigned', true,... 'WordLength', 32, ... 'FractionLength', 0 );
Specify Types for Conceptual Argument
These examples show some common type specifications using
createAndAddConceptualArg
.
hEntry = RTW.TflCOperationEntry; % . % . % . % uint8: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'uint8'); % single: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'single' ); % double: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'Type', 'double' ); % boolean: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'boolean' ); % complex: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'Type', 'cint16' ); % matrix of complex integers: createAndAddConceptualArg(hEntry, 'RTW.TflArgMatrix', ... 'Name', 'mat_in1', ... 'IOType', 'RTW_IO_INPUT', ... 'BaseType', 'cint8', ... 'DimRange', [2 1; Inf Inf]); % Fixed-point using binary-point-only scaling: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'Type', 'fixdt(1,32,28)'); % Fixed-point using [slope bias] scaling: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'Type', 'fixdt(1,16,15,2)');
Specify Type Properties for Conceptual Argument
These examples show how to specify types by using several properties of the data type.
hEntry = RTW.TflCOperationEntry; % . % . % . % uint8: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'IsSigned', false, ... 'WordLength', 8, ... 'FractionLength', 0 ); % single: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'single' ); % double: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'DataTypeMode', 'double' ); % boolean: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'u1', ... 'IOType', 'RTW_IO_INPUT', ... 'DataTypeMode', 'boolean' ); % Fixed-point using binary-point-only scaling: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'CheckSlope', true, ... 'CheckBias', true, ... 'DataTypeMode', 'Fixed-point: binary point scaling', ... 'IsSigned', true, ... 'WordLength', 32, ... 'FractionLength', 28); % Fixed-point using [slope bias] scaling: createAndAddConceptualArg(hEntry, 'RTW.TflArgNumeric', ... 'Name', 'y1', ... 'IOType', 'RTW_IO_OUTPUT', ... 'CheckSlope', true, ... 'CheckBias', true, ... 'DataTypeMode', 'Fixed-point: slope and bias scaling', ... 'IsSigned', true, ... 'WordLength', 16, ... 'Slope', 15, ... 'Bias', 2);
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; % . % . % . createAndAddConceptualArg(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 a conceptual 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.createAndAddConceptualArg('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 table
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.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. For input arguments, the name must be 'u1'
,
'u2'
, or follow the format
'un'
. For output arguments,
the name must be 'y1'
, 'y2'
, or follow
the format 'yn'
.
Example: 'Name','y1'
Example: 'Name','u1'
varargin
— Name-value pair arguments that specify the conceptual argument
name-value pair
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'
(default) | 'RTW_IO_OUTPUT'
Use value 'RTW_IO_INPUT'
for input or value
'RTW_IO_OUTPUT'
.
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
Integer specifying the word length, in bits, of the argument. The
default is 16
.
Example: 'WordLength',16
CheckSlope
— Selects whether to check that the slope value of the argument exactly matches the call-site slope value
true
(default) | false
Boolean flag that, when set to true
for a
fixed-point argument, causes code replacement request processing to
check that the slope value of the argument exactly matches the call-site
slope value.
Specify true
if you are matching a specific [slope
bias] scaling combination or a specific binary-point-only scaling
combination on fixed-point operator inputs and output. Specify
false
if you are matching relative scaling or
relative slope and bias values across fixed-point operator inputs and
output.
Example: 'CheckSlope',true
CheckBias
— Selects whether to check that the bias value of the argument exactly matches the call-site bias value
true
(default) | false
Boolean flag that, when set to true
for a
fixed-point argument, causes code replacement request processing to
check that the bias value of the argument exactly matches the call-site
bias value.
Specify true
if you are matching a specific [slope
bias] scaling combination or a specific binary-point-only scaling
combination on fixed-point operator inputs and output. Specify
false
if you are matching relative scaling or
relative slope and bias values across fixed-point operator inputs and
output.
Example: 'CheckBias',true
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'
Specify the data type scaling of the argument as
'BinaryPoint'
for binary-point scaling or
'SlopeBias'
for slope and bias scaling.
Example: 'Scaling','BinaryPoint'
Slope
— Specifies the slope of the argument
1
(default) | floating-point value
If you are matching a specific [slope bias] scaling combination on
fixed-point operator inputs and output, specify either this parameter or
a combination of the SlopeAdjustmentFactor
and
FixedExponent
parameters.
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
If you are matching a specific [slope bias] scaling combination on
fixed-point operator inputs and output, specify either the
Slope
parameter or a combination of this
parameter and the FixedExponent
parameter.
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
If you are matching a specific [slope bias] scaling combination on
fixed-point operator inputs and output, specify either the
Slope
parameter or a combination of this
parameter and the SlopeAdjustmentFactor
parameter.
Example: 'FixedExponent',-15
Bias
— Specifies the bias of the argument
0.0
(default) | floating-point value
Specify this parameter if you are matching a specific [slope bias] scaling combination on fixed-point operator inputs and output.
Example: 'Bias',2.0
FractionLength
— Specifies the fraction length for the argument
15
(default) | integer value
Specify this parameter if you are matching a specific binary-point-only scaling combination on fixed-point operator inputs and output.
Example: 'FractionLength',15
BaseType
— Specifies the base data type for which a matrix argument is valid
character vector | string scalar
Example: 'BaseType','double'
DimRange
— Specifies the dimensions for which a matrix argument is valid
matrix dimensions
You can also specify a range of dimensions specified in the format
[Dim1Min Dim2Min ... DimNMin; Dim1Max Dim2Max ...
DimNMax]
. For example, [2 2; inf inf]
means a two-dimensional matrix of size 2x2 or larger.
Example: 'DimRange',[2 2]
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 conceptual argument
handle
The arg
is a handle to the created conceptual
argument. Specifying the return argument in the
createAndAddConceptualArg
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 (한국어)