You can define data arguments forMATLAB Functionblocks using the following methods:
Method | For Defining | Reference |
---|---|---|
Define data directly in theMATLAB Functionblock code | Input and output data | SeeDefine Inputs and Outputs. |
Use the Ports and Data Manager | Input, output, and parameter data in theMATLAB Functionblock that is open and has focus | SeeDefining Data in the Ports and Data Manager. |
Use the Model Explorer | Input, output, and parameter data inMATLAB Functionblocks at all levels of the model hierarchy | SeeModel Explorer |
To add a data argument, in the Ports and Data Manager, selectAdd>Dataand modify the data properties.
You can set the following properties in the General tab:
Property | Description |
---|---|
Name | Name of the data argument, following the same naming conventions used in MATLAB®. |
Scope | Where data resides in memory, relative to its parent. Scope determines the range of functionality of the data argument. You can set scope to one of the following values:
For more information, seeDefine Inputs and OutputsandAdd Parameter Arguments. |
Port | argumen指数相关的端口数据t. This property applies only to input and output data. |
Tunable | Indicates whether the parameter used as the source of this data item is tunable (seeTunable Parameters). This property applies only to parameter data. Clear this option if the parameter must be a constant expression, such as for MATLAB toolbox functions supported for code generation (seeFunctions and Objects Supported for C/C++ Code Generation). |
Data must resolve to Simulink signal object | Specifies that the data argument must resolve to a Simulink®signal object. This property applies only to output data. This property appears only if you set the model configuration parameterSignal resolutionto a value other thanNone . SeeSymbol Resolutionfor more information. |
Size | Size of the data argument. Size can be a scalar value or a MATLAB vector of values. Size defaults to –1, which means that it is inherited, as described inInheriting Argument Sizes from Simulink. This property does not apply to Data Store Memory data. For more details, seeSize Function Arguments. |
Variable Size | Indicates whether the size of this data item is variable. This property does not apply to Data Store Memory data. |
Complexity | Indicates real or complex data arguments. You can set complexity to one of the following values:
|
Type |
For more information, seeSpecifying Argument Types. |
Unit (e.g., m, m/s^2, N*m) | Specify physical units for input and output data. By default, the property is set to inherit the unit from the Simulink signal on the corresponding input or output port. SeeUnits in MATLAB Function Blocks. |
Limit range | 为输入o指定可接受的值的范围内r output data. TheMATLAB Functionblock uses this range to validate the input or output as it enters or leaves the block. You can enter an expression or parameter that evaluates to a numeric scalar value.
|
You can set the following properties on the Description tab:
Property | Description |
---|---|
Save final value to base workspace | TheMATLAB Functionblock assigns the value of the data argument to a variable of the same name in the MATLAB base workspace at the end of simulation. |
Description | Description of the data argument. |
Document link | Link to documentation for the data argument. You can enter a Web URL address or a MATLAB command that displays documentation in a suitable format, such as an HTML file or text in the MATLAB Command Window. When you click the blue text,Document link, displayed at the bottom of theDataproperties dialog, theMATLAB Functionblock evaluates the link and displays the documentation. |