Error Appears while Using Simulink® Design Optimization™ to Estimate Model Parameters for RC Circuit Model
3 次查看(过去 30 天)
显示 更早的评论
Good day ladies and gentlemen. I am new to the Simulink® Design Optimization™. Just now I tried to practice with the example found in the following link: http://uk.mathworks.com/help/sldo/examples/estimate-model-parameters-and-initial-states-code.html
I keyed in all the commands in the example step by step. Below is the commands that I have entered: open_system('sdoRCCircuit');
% Get the measured data. load sdoRCCircuit_ExperimentData
% Create an experiment object to store the experimental voltage data. Exp = sdo.Experiment('sdoRCCircuit');
% Create an object to store the measured capacitor voltage output. Voltage = Simulink.SimulationData.Signal; Voltage.Name = 'Voltage'; Voltage.BlockPath = 'sdoRCCircuit/PS-Simulink Converter'; Voltage.PortType = 'outport'; Voltage.PortIndex = 1; Voltage.Values = timeseries(data,time);
% Add the measured capacitor data to the experiment as the expected output data. Exp.OutputData = Voltage;
% Create a simulation scenario using the experiment and obtain the simulated output. Simulator = createSimulator(Exp); Simulator = sim(Simulator);
% Search for the voltage signal in the logged simulation data. SimLog = find(Simulator.LoggedData,get_param('sdoRCCircuit','SignalLoggingName')); Voltage = find(SimLog,'Voltage');
% Plot the measured and simulated data. The model response does not match the experimental output data. plot(time,data,'ro',Voltage.Values.Time,Voltage.Values.Data,'b') title('Simulated and Measured Responses Before Estimation') legend('Measured Voltage','Simulated Voltage')
% Select the capacitance parameter from the model. Specify an initial guess for the capacitance value (460 uF) and a minimum bound (0 F). p = sdo.getParameterFromModel('sdoRCCircuit','C1'); p.Value = 460e-6; p.Minimum = 0;
% Create an estimation objective function to evaluate how closely the simulation output, generated using the estimated parameter value, matches the measured data. % Use an anonymous function with one input argument that calls the sdoRCCircuit_Objective function. We pass the anonymous function to sdo.optimize, which evaluates the function at each optimization iteration. estFcn = @(v) sdoRCCircuit_Objective(v,Simulator,Exp);
% To examine the estimation object function in more detail, type edit sdoRCCircuit_Objective at the MATLAB command prompt. type sdoRCCircuit_Objective
% Use the sdo.optimize function to estimate the capacitance value. % Specify the optimization options. The estimation function sdoRCCircuit_Objective returns the error residuals between simulated and experimental data and does not include any constraints, making this problem ideal for the 'lsqnonlin' solver. opt = sdo.OptimizeOptions; opt.Method = 'lsqnonlin';
% Estimate the parameters. pOpt = sdo.optimize(estFcn,p,opt)
However, I am stuck with the last command. The following error message occur when I tried to run the command: Error using sdo.optimize (line 116) The function handle passed to the optimize command encountered an error when evaluated with a parameter vector.
Caused by: Error using sdoRCCircuit_Objective Too many input arguments.
Can anyone here help me how to fix this problem? Thank you very much.
2 个评论
Swarooph
2016-7-12
A couple of fundamental questions:
1. What version of MATLAB are you using?
2. Do you have Simulink Design Optimization installed?
You can copy the output of the ver command here to answer all these questions.
P.S: Note that this will also give the license number. You can delete that out of your reply if you want.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!