How to create a Vector of Parameter Objects from a Simulink Model?

조회 수: 9 (최근 30일)
Javier Hoogendijk Abril
Javier Hoogendijk Abril 2024년 6월 7일
답변: Balavignesh 2024년 6월 17일
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:

답변 (1개)

Balavignesh
Balavignesh 2024년 6월 17일
Hi Javier,
It seems like you're working on a complex task involving the creation of a Dual Polaristion Battery Model in Simulink, and you are using 'sdo.optimize' to fine-tune the parameters of your model based on a cost function. While I would need access to your model to fully reproduce and address the issue, I've identified a few areas in the snippet you've provided that could be causing problems, along with some missing details.
  • Typo in param.Comtinuous in the line where you have defined 'R2_initial'. It should be 'param.Continuous'.
  • The syntax for defining parameters using 'param.Continuous' seems off. You forgot to use a comma (,) after the parameter name string, followed by the initial value when defining 'Ro_initial'.
  • The crucial part of your optimization, the cost function 'costFunction', is mentioned but not defined in the snippet. Ensure your cost function is properly defined to accept the parameters and the experiment as inputs and returns the cost based on the difference between the model output and the experimental data.
I recommend making these adjustments and giving it another try. Additionally, you might find the following documentation links useful for further information:
Hope that helps!
Balavignesh

카테고리

Help CenterFile Exchange에서 Estimate Parameters and States에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by