Why do I get an error when I changed the Output data type of a block in Simulink 7.2 (R2008b) to double ?

2 views (last 30 days)
I have a simple model with a Constant block followed by a Gain block. Originally, the Output data type of the Constant block was set to "uint32" and the model runs fine. However, when I simply changed the Output data type to double, I get the following error message:
Variable 'u' is used in incompatible ways in the dialog fields of the following: ex1_param_attrib_conflict/Constant, ex1_param_attrib_conflict/Gain. The variable's value is being used both directly and after a transformation. Only one of these usages is permitted for any given variable.
Note that the variable "u" in my workspace is a double data type variable:
>> whos
Name Size Bytes Class Attributes
u 1x1 8 double

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Starting with Simulink 5.1 (R13SP1), when a tunable parameter is defined as a double data type in the workspace, Simulink treats this variable as an "undefined" data type variable. Thus, during an update or at the start of the Simulation, Simulink tries to find the data type definition in the model. The error message is a result of Simulink finding more than one conflicting data type declarations for the same parameter. This behavior is mentioned in the following Simulink 5.1 (R13SP1) release notes (execute the WEB command in MATLAB):
web([docroot '/toolbox/simulink/rn/bqmg7gg-1_1.html#bqmiupg-8'])
For the attached model, note that the Gain block defines the same parameter "u" to be a "uint32" data type variable. To see this, right click on the Gain block and select Gain Parameters -> Parameter Attributes. Thus, any of the following options should resolve the issue:
1. Modify / Remove the inconsistent data type definitions. In this example, either change the Output data type of the Constant block to "uint32" or the data type of the parameter in the Gain block to "double"
2. Declare the variable in the workspace as a non-double data type variable. MATLAB allows the creation of variables without declaring its data type. Although these variables are actually defined as double data types, it can also be interpreted as "undefined" data type variables. This is the same concept that Simulink tries to apply. Thus, in the example, declaring the variable "u" as a "uint32" data type variable also resolves the issue.
3. DO NOT specify "u" as a tunable parameter when the "Inline Parameters" option is enabled. This also resolves the issue since Simulink simply copies the value of the variable in the workspace and no longer treats it as an "undefined" data type variable.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2008b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!