Batch simulink problem
12 ビュー (過去 30 日間)
古いコメントを表示
Hi all
I'm busy doing batch runs of my Simulink model using the command line 'sim' function in a Matlab script.
What I'm finding now is that after a random amount of runs (100 or more), the simulation crashes by saying one of the outputs of my S-functions is NAN or INF.
but if I type 'clear all' and run the exact same input parameters in model, it works. Very strange...
I've tried different integration solvers, to no avail. I've tried reducing step sizes.
I'm thinking maybe it has something with the way S-functions handle memory. Do S-functions keep their memory after a simulation run? Is there a way I can clear the memory allocated for my S-function, before I run the 'sim' command?
I'm really stumped on this one, so any ideas would be much appreciated.
Amir
2 件のコメント
Kaustubha Govind
2011 年 8 月 6 日
Try using "clear mex" before each simulation and see if it helps? S-functions typically don't keep their memory between simulation runs, but the onus of clearing/destroying memory is on the S-function author. So you might want to check if your S-functions allocate global/static memory that is not being flushed.
回答 (1 件)
Fangjun Jiang
2011 年 8 月 6 日
I am not sure. Memory could be the reason. To solve the problem, is it practical for you to put "clear all" or some types of clear memory command in your batch? That might be the easy solution. Or, if your repeating simulation run is iterative, it might be that the simulation is eventually unstable, i.e. one of the outputs of the S-funciton is indeed NaN or INF. By doing clear all, you won't be able to duplicate the problem manually.
When the problem happens, will you be able to check all your workspace variables to see if anything is abnormal? Will you be able to start the simulation manually, for a short period of time, to see what is going on with the simulation?
2 件のコメント
Fangjun Jiang
2011 年 8 月 6 日
Yes. They way you save all the variables to .mat file and then recover is a smart move to debug the problem. I don't have much more advise except that maybe run "clear function", or "clear mex" and others (help clear to see all the other thing to clear) instead of "clar all". Just a way to nail down the problem if possible.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!