MATLAB Answers

0

Why can't I use variables of type int64/uint64 as block parameter in Simulink?

I have a variable of type int64/uint64 in MATLAB workspace. When I try to specify this variable as parameter for a Constant or Gain block, I get below errors:
Invalid setting in 'MyModel/Constant' for parameter 'Value'.
Invalid setting in 'MyModel/Gain' for parameter 'Gain'.
I get the same error if I directly enter expressions such as "uint64(1)" as block parameter.

Tags

No tags entered yet.

Products


Release

R2019a

1 Answer

Answer by MathWorks Support Team on 8 Aug 2019
 Accepted Answer

While int64 and uint64 are supported as built-in Simulink data types since R2019a, int64/uint64 variables as block parameters are not yet supported.
The restriction is specifically with the 'Value' parameter of Constant, or similar edit-boxed blocks (e.g. Gain blocks, Bias blocks, etc.). int64/uint64 are supported for simulation, but values cannot be cast to it.
In R2019a and later, as long as the "Output data type" is set to the correct data type, the type during simulation will be int64/uint64:
>> set_param(gcb,'Value','1')
>> set_param(gcb,'OutDataTypeStr','int64') % only available in 19a and later
To create a value with the desired data type, you can also use a Simulink.Parameter and set the data type information using the 'DataType' field. This will make sure that the value in Simulink is a 64-bit integer without needing to specify it in the 'Value' field. For example:
>> x = Simulink.Parameter(1000);
>> x.DataType = 'int64';
Unfortunately, the 'Value' of the Simulink.Parameter cannot be a 64-bit integer, but Simulink will treat operations as 64-bit since the DataType is specified as such.
An enhancement request has been submitted to development to improve the error message, and add support for int64/uint64 variables as block parameters.

  0 Comments

Sign in to comment.