how to simulate a model with inputs from multiple bus containing uint64 ?

3 次查看(过去 30 天)
Previously I was using fromworkspace block to Read struct of timeseries to simulate models.
Since our bus contain uint64, it doesn't work anymore.
I try to use Simulink.SimulationData.createStructOfTimeseries to alocate bus to an input. But while generating the it generate the folowing error : "Invalid argument for structure timeseries initialization. Element 10 is of type uint64 but the bus object requires type embedded.fi."
Furthermore Simulink.SimulationData.createStructOfTimeseries seems to create only one input port and I wich to create multiple input port for multiple bus.

回答(1 个)

Pratyush
Pratyush 2023-8-3
I understand that you are getting invalid argument for type uint64 and you want to create multiple input ports for multiple buses.
The error message suggests that the bus object you're using requires elements of type `embedded.fi`, but you're providing a `uint64` type. The `embedded.fi` data type is a fixed-point representation in MATLAB. To resolve this issue, you can convert your `uint64` data to `embedded.fi` using the `fi` function. Here's an example:
% Assuming your uint64 data is stored in a variable called 'myData'
fiData = fi(myData, 0, 64); % Convert uint64 to embedded.fi
% Now you can use fiData in your Simulink model
By default, the `Simulink.SimulationData.createStructOfTimeseries` function creates a single input port for the generated bus. If you want to create multiple input ports for multiple buses, you can create a cell array of bus objects and then pass it to the function. Each bus object in the cell array will correspond to a separate input port. Here's an example:
% Assuming you have two bus objects: busObject1 and busObject2
busObjects = {busObject1, busObject2};
% Create a struct of timeseries using the bus objects
data = Simulink.SimulationData.createStructOfTimeseries(busObjects);
% Now 'data' will contain multiple input ports, each corresponding to a bus object
  1 个评论
Gaetan LE GALL
Gaetan LE GALL 2023-8-4
Thanks for your answer
unfurtunately it seems I don't have licenece for 'fi' function :
>> a = fi(pi)
Error using embedded.fi/fifactory
Unable to check out a license for the Fixed-Point Designer.
Error in fi (line 226)
a = embedded.fi(varargin{:}); - Show complete stack trace
In the Simulink.bus definition, I only set Datatype of my signal to uint64 all other is set by default (builtin uint64). I didn't define specific format. So I don't understand needs to recreate a specific format with fi.

请先登录,再进行评论。

类别

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

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by