SimState error

7 views (last 30 days)
Fabio
Fabio on 12 May 2012
Hello, i'm working with Simulink and I have a problem: I start a simulation and every 'T' time I need to stop it, save the state of the system as Simstate, and then restore the system state by changing a few variables. For example, I am working with the base model 'Inverted Pendulum with Animation' (penddemo.mdl), and when I restore the state I must change the mass of the pendulum, here's some code:
set_param('penddemo','LoadInitialState','on','InitialState','init_state'); % load the initial state
set_param('penddemo','SaveFinalState','on','FinalStateName', 'xFinal','SaveCompleteFinalSimState', 'on'); % save the complete simstate
set_param('penddemo/Pendulum','Mcart','0.600'); % change the mass
sim('penddemo',time); %starting the simulation
The problem is that I get this error:
can not load the Simulink SimState Because The initial model, 'penddemo', was changed after the SimState was saved. Run the simulation again and resave the SimState.
I know that there are limitations in the use of Simstate:
You cannot make any structural changes to the model between the time at which you save the SimState and the time at which you restore the simulation using the SimState. For example, you cannot add or remove a block after saving the SimState without repeating the simulation and saving the new SimState.
but I do not think changing a single variable is a structural change and Mcart is a tunable parameter. Maybe someone knows another way to change some variables before the recovery of Simstate.
  1 Comment
Abdullah Mohiuddin
Abdullah Mohiuddin on 4 Oct 2017
Hi,
I came across a similar problem, I also wish to change some parameters before resuming the simulation. Did you find a workaround? Is there any other way we can change some variables and resume the simulation?

Sign in to comment.

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 24 May 2012
The parameter 'Mcart' on the block 'penddemo/Pendulum' is used under the mask in a Fcn block in the "Expression" parameter, which is non-tunable (ie. cannot change between a SimState save and restore). So you cannot change the value of 'Mcart' because it counts as a structural change.
  4 Comments
Robert Garnett
Robert Garnett on 9 Feb 2014
Hi,
Yes I would agree however in my view the absolute time starting point is simply an initial condition so what's the problem? If you select "Structure With Time" you have the end time anyway
We have a power plant simulator that models a boiler and turbine including combustion from first principles. There are ten's of thousands of states in this model. This model has absolute time and we can save states for use as plant initial conditions and then reload them without any issues.
We cannot of course use initial conditions generated with a different model structure, however we can make gain changes and whilst this will cause an initial disturbance at start-up usually the model will still converge and run normally.
The problem with using the initial final states as initial conditions in simulink is that the very act of checking the "Initial State" Load from Workspace checkbox in the Config Pars dialog seems to make the model "dirty" which stops it from using the xFinal states variable in the workspace.
I hope this explanation is of assistance.
Regards
Rob
Abdullah Mohiuddin
Abdullah Mohiuddin on 4 Oct 2017
Hi, so is there anything we can change before resuming the state and how?

Sign in to comment.

More Answers (0)

Categories

Find more on General Applications 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!