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.
댓글 수: 0
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!