Why does simulink recompiles the simulation every time when using sim command?

10 views (last 30 days)
Im trying to call to sim multiple times through a for loop. The only things that changes each iteration are the values of the plecs parameters blocks inside(the simulation input).
But every time i click the run button of the model it shows the recompilation process in a green box below(a picture is attached).
How can i do compilation only once and in the other times the simulation will just run with the new input ? The problem is that each compilation takes about two seconds and it a long time when using long for loops.

Answers (2)

Andreas Goser
Andreas Goser on 21 Jun 2016
The "Plecs" keyword suggests there might be a non MathWorks product involved. Can you confirm? Can you try to remove that 3rd party block(s) for debugging purpose and see whether it still recompiles? This is to narrow down if a Simulink or a Plecs specialist is needed.

omer
omer on 21 Jun 2016
Edited: omer on 21 Jun 2016
Hey Andreas , thanks for the quick answer. Becasue my model are with only plecs blocks there will be nothing left if i remove it. So i created a blank model -constant conected to outport in simulink. and I pressed the run button . Every time i press the run button its doing fast intialization and compilation(i mean there is still the green box but its very fast , i guess because of the simple model).
when clicking the run button in the original simulation with plecs , its compiling in two stages :
"Compiling:Performing precompile notifications: Started" and right after : "Compiling: Evaluating block parameters : Started"
Another important detail is that in these plecs blocks i use C script Blocks that calculate the outputs for current inputs
  2 Comments
Andreas Goser
Andreas Goser on 21 Jun 2016
I see. When this green progress bar promts "compiling" it does very differnt things under the hood. Some of them may be actual "compiling", some not. So basically you point is how to speed that up. I really cannot say that for PLECS. Maybe there is a PLECS specific forum? Certainly also here on MATLAB Answers other users maybe have that experience.
omer
omer on 21 Jun 2016
Thing is , that even if i dont change the input, and press on 'run' it recompiles. I checked the PLECS manual and it says that i should define this parameters as tunable instead of inline in simulink. but the problem is that i dont know how to do so. Any suggestions?

Sign in to comment.

Categories

Find more on Simulink Functions 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!