| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Real-Time Workshop |
| Contents | Index |
| Learn more about Real-Time Workshop |
If you are using tunable workspace parameters, you need to be aware of potential issues regarding data types. A workspace parameter is tunable when the following conditions exist:
You select the Inline parameters option on the Optimization pane of the Configuration Parameters dialog box
The parameter has a storage class other than Auto
When generating code for tunable workspace parameters, the Real-Time Workshop product checks and compares the data types used for a particular parameter in the workspace and in Block Parameter dialog boxes.
| If... | The Real-Time Workshop Product... |
|---|---|
| The data types match | Uses that data type for the parameter in the generated code. |
| You do not explicitly specify a data type other than double in the workspace | Uses the data type specified by the block in the generated
code. If multiple blocks share a parameter, they must all specify
the same data type. If the data type varies between blocks, the product
generates an error similar to the following:Variable 'K' is used in incompatible ways in the dialog fields of the following: cs_params/Gain, cs_params/Gain1. The variable'value is being used both directly and after a transformation. Only one of these usages is permitted for any given variable. |
| You explicitly specify a data type other than double in the workspace | Uses the data type from the workspace for the parameter. The block typecasts the parameter to the block specific data type before using it. |
The following table provides guidelines on specifying data types for tunable workspace parameters.
| If You Want to... | Then Specify Data Types in... |
|---|---|
| Minimize memory usage (int8 instead of single) | The workspace explicitly |
| Avoid typecasting | Blocks only |
| Interface to legacy or custom code | The workspace explicitly |
| Use the same parameter for multiple blocks that specify different data types | The workspace explicitly |
The Real-Time Workshop product enforces limitations on the use of data types other than double in the workspace, as explained in Limitations on Specifying Data Types in the Workspace Explicitly.
When you explicitly specify a data type other than double in the workspace, blocks typecast the parameter to the appropriate data type. This is an issue for blocks that use pointer access for their parameters. Blocks cannot use pointer access if they need to typecast the parameter before using it (because of a data type mismatch). Another case in which this occurs is for workspace variables with bias or fractional slope. Two possible solutions to these problems are
Remove the explicit data type specification in the workspace for parameters used in such blocks.
Modify the block so that it uses the parameter with the same data type as specified in the workspace. For example, the Lookup Table block uses the data types of its input signal to determine the data type that it uses to access the X-breakpoint parameter. You can prevent the block from typecasting the run-time parameter by converting the input signal to the data type used for X-breakpoints in the workspace. (Similarly, the output signal is used to determine the data types used to access the lookup table's Y data.)
![]() | Generated Code for Parameter Data Types | Parameter Tuning by Using MATLAB Commands | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |