How can I Generate separate function from different simulink subsystem. I am using Matlab 2017a. Normally in simulink all the subsystem blocks will be combined after generating code. Can anyone suggest. How can I Generate separate function from diffe

 Accepted Answer

  • select the subsystem block
  • right click
  • select "C/C++ Code"
  • select "Build This Subsystem" or "Export Functions"

3 Comments

But this will only generate that subsystem's code. I think the user wants to generate separate function for that subsystem in overall code.
You need to do what I say for all of your subsystems.

Sign in to comment.

More Answers (1)

Right click on your subsystem choose Block Parameters(Subsystem). Then in Main pane, check Treat as atomic unit. After, go to next pane which is called Code Generation and set function packaging as Nonreusable function. It will explicitly generate a seperate function in a separate file. You may also set the function's and file's name by yourself.

Categories

Community Treasure Hunt

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

Start Hunting!