필터 지우기
필터 지우기

SimState error

조회 수: 9 (최근 30일)
Fabio
Fabio 2012년 5월 12일
댓글: Abdullah Mohiuddin 2017년 10월 4일
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
Abdullah Mohiuddin
Abdullah Mohiuddin 2017년 10월 4일
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?

댓글을 달려면 로그인하십시오.

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 5월 24일
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
Robert Garnett
Robert Garnett 2014년 2월 9일
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 2017년 10월 4일
Hi, so is there anything we can change before resuming the state and how?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by