What does the slreportgen.utils.compileModel function actually do to a model?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
What does the slreportgen.utils.compileModel(modelname) function actually do to a model? If I try to close the the compiled model without uncompiling it first, the following error is shown. What does the uncompile function do here?
load_system('sample.mdl')
slreportgen.utils.compileModel('sample.mdl')
%slreportgen.utils.uncompileModel('sample.mdl') works with this line
close_system('sample.mdl')
Error using close_system
Cannot close the model 'sample' when it is being compiled or while the simulation is running
On the other hand, I can successfully close the system after the sim function.
sim('sample.mdl')
close_system('sample.mdl')
What is the reason behind this behavior?
0 commentaires
Réponses (1)
Vaibhav
le 17 Nov 2023
Modifié(e) : Vaibhav
le 17 Nov 2023
Hi Mohammad
I understand that you would like to know the background working of "slreportgen.utils.compileModel(modelname)", "slreportgen.utils.uncompileModel(modelname)" and "sim(modelname)" functions.
The "slreportgen.utils.compileModel(modelname)" function takes the model name (modelname) as an argument and compiles the specified model. Once compiled, the model is loaded into memory, ready for simulation or code generation.
Uncompiling a Simulink model unloads the compiled model from memory. This frees up system resources and allows you to close the model without any issues. When you attempt to close a compiled model using "close_system('sample.mdl')" without first uncompiling it, the error is encountered, this is because the model is still loaded into memory.
To close a compiled model without errors, first uncompile it using "slreportgen.utils.uncompileModel('sample.mdl')." This frees up the system resources associated with the compiled model and allows to close it properly. When using the "sim('sample.mdl')" function to simulate a model, it automatically uncompiles the model after the simulation is complete. This behavior ensures that the compiled model is unloaded from memory only after the simulation has finished using it.
You can refer to the following MathWorks documentation links to know more about "slreportgen.utils.compileModel", "slreportgen.utils.uncompileModel" and "sim" functions respectively.
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Configure and View Diagnostics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!