필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Gaetan LE GALL
Gaetan LE GALL 2023년 7월 28일
댓글: Gaetan LE GALL 2023년 8월 4일
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