open_system("BatteryModel.slx");
load("OutputCurrent.mat");
load("OutputVoltage.mat");
V_Out = OutputVoltage.Data;
I_In = OutputCurrent.Data;
time = OutputVoltage.Time;
experiment = sdo.Experiment('BattteryModel');
input = Simulink.SimulationData.Signal;
input.Name = 'HPPC Input Signal';
input.Values = timeseries(I_In, time);
experiment.InputData = input;
output = Simulink.SimulationsData.Signal;
output.Name = 'Output Voltage';
output.Values = timeseries(V_Out, time);
experiment.OutputData = output;
R0_initial = param.Continuous('R0' 0.01);
R1_initial = param.Continuous('R1' 0.02);
R2_initial = param.Comtinuous('R2', 0.1);
C1_initial = param.Continuous('C1', 500);
C2_initial = param.Continuous('C2', 1000);
params = [R0_initial, R1_initial, R2_initial, C1_initial, C2_initial];
opt = sdo.OptimizeOptions;
opt.Method = 'lsqnonlin';
[est_params, info] = sdo.optimize(@(p) costFunction(p, experiment), params, opt);