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

3 vues (au cours des 30 derniers jours)
Gaetan LE GALL
Gaetan LE GALL le 28 Juil 2023
Commenté : Gaetan LE GALL le 4 Août 2023
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.

Réponses (1)

Pratyush
Pratyush le 3 Août 2023
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 commentaire
Gaetan LE GALL
Gaetan LE GALL le 4 Août 2023
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.

Connectez-vous pour commenter.

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by