How can I stop my Simulink model from generating slprj folder and .mex* files?

208 views (last 30 days)
Hello,
Currently in part of my Simulink model I am using a Matlab fcn block to do some calculations. This block causes the model to create a .mexw32 file before running. How can I get the same functionality without the need of this extra file?
Also, many times when compiled the model a "slprj" folder will be created in the current directory. This folder does not appear to be necessary for the model to run. How can I stop this folder from being created?
According to the documentation found below, both of these items can be detrimental to a Simulink simulation. Because of that, I would like to know how I can stop generating them. http://www.mathworks.com/help/simulink/ug/work-with-derived-files-in-projects.html
Thank you.

Answers (1)

Guy Rouleau
Guy Rouleau on 16 Oct 2013
What the link below says about those files is "exclude them from source control". It does not say that they are detrimental in general.
The mainthing you need to keep in mind is that those files are not bad... not at all. In many cases, generating a mex-file speeds the simulation of your model.
The only disadvantage I can see of having an slprj folder created and a mex-file is that the update time of your model takes longer... this is trade off to make the simulation faster.
If this is very important for you to not generate mex-file and slprj folder (not for the reasons you mention), you can use the Interpreted MATLAB Function block of a MATLAB s-function instead... those do not generated code.
  3 Comments
Guy Rouleau
Guy Rouleau on 17 Oct 2013
The slprj folder is used to generate the mex-file. One thing you can do is configure Simulink to put that code somewhere... look at the Simulink preferences
craq
craq on 30 Jan 2014
I'd also like to avoid all those slprj folders cluttering up my working directories. The specific preference to look at is at the top level (Simulink Preferences). Under "File Generation Control", set "Simulation cache folder".
Note that if you want to do code generation, you have to change both this setting and the one underneath it (Code Generation Folder). Simulink doesn't seem to cope well with having one of these customised and one set to the default. (It seems to be otherwise arbitrary which folders you choose, as long as you don't happen to have one of them as your current working directory.)

Sign in to comment.

Categories

Find more on Event Functions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!