createAndAddConceptualArg
Create conceptual argument from specified properties and add to conceptual arguments for code replacement table entry
Description
Examples
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 );
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)');
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);
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');
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
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
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 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'
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'
Use value 'RTW_IO_INPUT'
for input or value
'RTW_IO_OUTPUT'
.
Example: 'IOType','RTW_IO_INPUT'
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)'
Boolean value that, when set to true
, indicates
that the argument is signed.
Example: 'IsSigned',true
Integer specifying the word length, in bits, of the argument. The
default is 16
.
Example: 'WordLength',16
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
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
You can specify either DataType
(with
Scaling
) or DataTypeMode
, but
do not specify both.
Example: 'DataTypeMode','Fixed-point: binary point
scaling'
Example: 'DataType','Fixed'
Specify the data type scaling of the argument as
'BinaryPoint'
for binary-point scaling or
'SlopeBias'
for slope and bias scaling.
Example: 'Scaling','BinaryPoint'
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
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
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
Specify this parameter if you are matching a specific [slope bias] scaling combination on fixed-point operator inputs and output.
Example: 'Bias',2.0
Specify this parameter if you are matching a specific binary-point-only scaling combination on fixed-point operator inputs and output.
Example: 'FractionLength',15
Example: 'BaseType','double'
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]
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
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 R2007bYou 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: United States.
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)