how to simulate a model with inputs from multiple bus containing uint64 ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
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
Voir également
Catégories
En savoir plus sur Sources dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!