Effacer les filtres
Effacer les filtres

Return structure from setExternalInputsFcn

3 vues (au cours des 30 derniers jours)
William Stokes
William Stokes le 15 Mar 2022
Commenté : Alvaro le 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 commentaire
Alvaro
Alvaro le 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?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by