How to use SimState when estimating parameters using Simulink Design Optimization?
1 次查看(过去 30 天)
显示 更早的评论
I have a model of a dynamic system where I wish to estimate some model parameters using experimental data. I also wish to the simulation to start from a steady-state and for that I saved a state using SimState.
However when I try to do the parameter estimation following the example given in Estimate Model Parameters Per Experiment (Code). I get the error message: "Error using sdo.SimulationTest/sim (line 616) Simulink cannot load the initial SimState because the model, 'sdoBattery', was changed after the SimState was saved. Run the simulation again and resave the SimState."
How should I do the able to use a SimState when I do parameter estimation?
Based on the SdoBattery-example, the following code replicates my error:
open_system('sdoBattery');
load sdoBattery_ExperimentData
DCharge_Exp = sdo.Experiment('sdoBattery');
DCharge_Exp.InputData = timeseries(DCharge_Data(:,2),DCharge_Data(:,1));
VoltageSig = Simulink.SimulationData.Signal;
VoltageSig.Name = 'Voltage';
VoltageSig.BlockPath = 'sdoBattery/SOC -> Voltage';
VoltageSig.PortType = 'outport';
VoltageSig.PortIndex = 1;
VoltageSig.Values = timeseries(DCharge_Data(:,3),DCharge_Data(:,1));
DCharge_Exp.OutputData = VoltageSig;
Q0 = sdo.getParameterFromModel('sdoBattery','Q0');
Q0.Value = 6.5;
Q0.Free = false;
DCharge_Exp.Parameters = Q0;
%some "steady-state" data
for i = 1:18005
for j = 1:4
SteadyState_Data(i,j) = DCharge_Data(i,j);
end
end
%experimental data for parameter estimation
for i = 18006:135004
for j = 1:4
Exp_Data(i-18005,j) = DCharge_Data(i,j);
end
end
model = 'sdoBattery';
set_param(model,'LoadInitialState','off','InitialState', [model 'SimState']);
set_param(model, 'SaveFinalState', 'on', 'FinalStateName', ...
[model 'SimState'], 'SaveCompleteFinalSimState', 'on', 'ExternalInput', 'SteadyState_Data')
res= sim(model, 3600);
set_param(model, 'SaveFinalState', 'off', 'FinalStateName', ...
[model 'SimState'], 'SaveCompleteFinalSimState', 'off');
Simulator = createSimulator(DCharge_Exp);
Simulator.InitialState = [model 'SimState'];
Simulator = sim(Simulator);
3 个评论
Alec Stothert
2014-4-1
Unfortunately not, sdo.getStateFromModel finds "loggable" states but the solver states are not "loggable" and not detected by getStateFromModel. Also there isn't a way to get extract the solver states from SimState and use that in conjunction with sdo.getStateFromModel.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Estimate Parameters and States 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!