Dependencies in Simulink Functions(/Function Caller)

Hi all,
I have only just started using Simulink function and I have come across the problem of trying to 'extract' all the 'common' (/dependencies) functions (typically sin, cos, atan, mod, etc...) across different Referenced Models and place them in their own Referenced Model. The ultimate goal is to code generate a number of Reference Models along with a State Flow state machine (the application).
What I would like to have is a Reference Model, lets call it "Math_Functions" which will have a number of Simulink Functions in it, each of which will contain a Matlab function block (within which I have a single function call to the appropriate math function).
Currently these dependencies are code generated in separate source and header files per function (per sin, cos, etc...). The same function is code generated multiple times (once for every reference model it exists in), which is what I am trying to avoid.
Using Matlab 2017b.
Any help or ideas much appreciated.
Thanks and regards Alex

Réponses (1)

Mark McBroom
Mark McBroom le 25 Fév 2018

0 votes

Best approach is to place each MATLAB Function block into an atomic subsystem and place in a Simulink library. COnfigure the atomic subsystem to generate reusable code. You will get one c function in /slprj/ert/_sharedutils. This blog gives details.

1 commentaire

Alex Bogias
Alex Bogias le 26 Fév 2018
Modifié(e) : Alex Bogias le 26 Fév 2018
Thanks for taking the time to reply Mark.I really appreciate it.
I will give your (/blog) suggestion a try.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Coder dans Centre d'aide et File Exchange

Modifié(e) :

le 26 Fév 2018

Community Treasure Hunt

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

Start Hunting!

Translated by