How to create a Vector of Parameter Objects from a Simulink Model?
I am trying to create a Dual Polarisation Battery Model on simulink. I am using the Optimization Toolbox to create an experiment to run a cost function to determine parameters for my model. My model has initial parameters, which are defined in my code but I am unable to run my cost function. I am also using the sdo.optimize to run my code. Part of my code can be seen below:
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);
The circuit I am using can be seen below:I am trying to create a Dual Polarisation Battery Model on simulink. I am using the Optimization Toolbox to create an experiment to run a cost function to determine parameters for my model. My model has initial parameters, which are defined in my code but I am unable to run my cost function. I am also using the sdo.optimize to run my code. Part of my code can be seen below:
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);
The circuit I am using can be seen below: I am trying to create a Dual Polarisation Battery Model on simulink. I am using the Optimization Toolbox to create an experiment to run a cost function to determine parameters for my model. My model has initial parameters, which are defined in my code but I am unable to run my cost function. I am also using the sdo.optimize to run my code. Part of my code can be seen below:
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);
The circuit I am using can be seen below: optimization, help, costfunction, simulink, matlab MATLAB Answers — New Questions