Borrar filtros
Borrar filtros

Return structure from setExternalInputsFcn

3 visualizaciones (últimos 30 días)
William Stokes
William Stokes el 15 de Mzo. de 2022
Comentada: Alvaro el 18 de En. de 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 comentario
Alvaro
Alvaro el 18 de En. de 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?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by