Filter löschen
Filter löschen

Return structure from setExternalInputsFcn

3 Ansichten (letzte 30 Tage)
William Stokes
William Stokes am 15 Mär. 2022
Kommentiert: Alvaro am 18 Jan. 2023
I am using simulink.compiler.setExternalInputsFcn to declare a callback function which returns a value to each input port at each timestep.
Something like
simin = similink.compiler.setExternalInputsFcn(simin, inputsFcn)
If the return value from this function is scalar, or an array this seems to work fine. However, I want to return a structure, which will be mapped to a bus in Simulink.
I create the bus type in my model data dictionary, and set it as the type for the input port. I declare the callback like so
function v = inputsFcn(id, t)
v = struct('a',1,'b',2,'c',3);
end
But trying to run this gives the following line in the error...
ExternalInputsFcn could not be enabled due to the following incompatibilities:
and further down...
Caused by:
Error using Simulink.Simulation.internal.DesktopSimHelper
The data type of root inport 1 is not of a supported type.
Is this not allowed???
  1 Kommentar
Alvaro
Alvaro am 18 Jan. 2023
Could you elaborate as to why you are trying to pass a struct into your inport?
I couldn't get simulink.compiler.setExternalInputsFcn to take a struct either but I am getting this error
The dimensions, data type or complexity of the return value from the ExternalInputsFcn for port 1 are incorrect.
Perhaps converting the struct to an array would work for you?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by