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

20 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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.

更多回答(1 个)

Andy Bartlett
Andy Bartlett 2020-5-19
编辑:Andy Bartlett 2020-5-19
In R2020a, Simulink parameters can now be entered using MATLAB built-in int64 and uint64 types.
For example, you can directly enter the Value parameter of a Constant block as
intmax('uint64')
In R2019a and earlier, you could not directly do this.
In those earlier releases, the work around was to simply to wrap the int64 or uint64 in a fi object constructor.
For example, for the Value of the Constant block you could enter
fi( intmax('uint64') )
In R2017a and later, this use of a fi object does NOT require a Fixed-Point Designer license.
Creating a fi object who's type is equivalent to a built-in does not require a license in R2017a and later.
In R2016b and earlier, a Fixed-Point Designer license was required.

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

标签

尚未输入任何标签。

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by