Dependencies in Simulink Functions(/Function Caller)

3 views (last 30 days)
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

Answers (1)

Mark McBroom
Mark McBroom on 25 Feb 2018
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 Comment
Alex Bogias
Alex Bogias on 26 Feb 2018
Edited: Alex Bogias on 26 Feb 2018
Thanks for taking the time to reply Mark.I really appreciate it.
I will give your (/blog) suggestion a try.

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!