Why the models stays in "paused after initialisation" state?

Hello all, Before Matlab R2013b I did not have a problem with this... I did a model compilation programmatically like this:
eval([bdroot '([],[],[],''compile'')']);
disp(' ');disp('Model compiled!');disp(' ');
eval([bdroot '([],[],[],''term'')']);
disp(' ');disp('Model terminated!');disp(' ');
It worked just fine. Now the model remains stuck in "paused after initialization" state and does not get out of this state even using GUI. You have to forcibly close Matlab in order to modify/save/update/do anything else with the model.
Did someone else had this problem or knows a way to make sure the model is compilable without going into this kind of trouble?
Thank you!

4 Comments

I have MATLAB 2013b and these commands are working for me on a simple model.
The model GUI is only "stuck" during 'compile', and after using 'term', it returns it to normal operation.
Are you sure the 'term' line is executing? Are you getting any other errors or warning messages? Perhaps you have some other error or more complicated condition in your model?
Hello,
First of all, I am using the 32 bit release. I hope it does not make any difference.
second point is the fact that I have a TargetLink model. Maybe it has something to do with that(although is does not seem to be a problem with other models).
Third point is the fact that I just want to see if I have a runnable model. Maybe is there another way to test this? I have (in the meanwhile) came up with
set_param(gcs, 'SimulationCommand', 'update');
set_param(gcs, 'SimulationCommand', 'stop');
for the moment instead of compile. Is this enough to be sure I have a compilable/runnable model?
What I actually do is something like(real test code now):
cd(mdlFolderName); % model folder
try
load_system('abaaaa.mdl');
disp(' ');disp('Model opened!');disp(' ');
eval([bdroot '([],[],[],''compile'')']);
disp(' ');disp('Model compiled!');disp(' ');
eval([bdroot '([],[],[],''term'')']);
disp(' ');disp('Model terminated!');disp(' ');
close_system('abaaaa.mdl', 0); % here the exception is generated
disp(' ');disp('Model closed!');disp(' ');
catch
disp(' ');disp('Model generated exception!');disp(' ');
end
and I get this answer:
Model opened!
Model compiled!
Model terminated!
Model generated exception!
a second run will generate:
Model opened!
Warning: 'abaaaa' is already compiled
> In tstComp at 4
Model compiled!
Warning: Termination of 'abaaaa' deferred
> In tstComp at 6
Model terminated!
Model generated exception!
Thank you!
Since I can't reproduce it, I am suspecting your compiler. I get the following:
Model opened!
Model compiled!
Model terminated!
Model closed!
I'm getting a similar problem. I'm trying to make use of the CompiledSampleTime property of a block, but finding that if I change the sample time then I have to compile twice to get it to work, because the first time it goes through it uses the previously compiled time. In attempting to get around this, I used the modelname([],[],[],'compile') command. Now my model window shows "Paused" in the bottom left, and if I try to do modelname([],[],[],'term') I just get the warning:
Warning: Termination of '<modelname>' deferred

Sign in to comment.

Answers (2)

The issue can be solved in Matlab 2017b in the following way:
eval([bdroot '([],[],[],''compile'')']);
disp(' ');disp('Model compiled!');disp(' ');
eval([bdroot '([],[],[],''sizes'')']);
eval([bdroot '([],[],[],''term'')']);
disp(' ');disp('Model terminated!');disp(' ');
The sizes command enables model termination.
Your usage looks right to me. There are a couple of things you can check here:
1) bdroot may refer to a different model after the call to compile. This can happen if the top model contains referenced model or if there are any model callbacks which interact with another model. Or if you simply click on another model between the call to compile and terminate. I suggest using a more explicit syntax to avoid this:
>> mdl = 'myModel'
>> feval(mdl, [], [], [], 'compile')
2) if the original code snippet is more than what you've shown, this may be due to the queued behvaior of compile and terminate commands: if compile command was issued more than once on the same model, without any calls to term in between, you would need to call term the same number of times to actually termiante the compilation. You should see warnings in this case though. For example:
>> feval(‘myModel’,[],[],[],’compile’);
>> feval(‘myModel’,[],[],[],’compile’); % Warning: myModel is already compiled
>> feval(‘myModel’,[],[],[],’term’); % Warning: Termination of 'myModel' deferred
>> feval(‘myModel’,[],[],[],’term’); %no warning; model compilation is undone.
Btw, I tried this in R2022a, and i see the compiled state labeled as 'compiled' on the UI, after the compilation call.

Categories

Products

Asked:

on 29 Jan 2015

Community Treasure Hunt

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

Start Hunting!