Error using fminsearch and optimset
Afficher commentaires plus anciens
Hi,
I am trying to calibrate parameters using experimental data and simulation results from simulink. But when I try to run it, Matlab gives me some errors. Below the errors:
>> CalibrationASM1_Namoniacal
Index exceeds matrix dimensions.
Error in optASM1 (line 10)
bh=p(3);
Error in fminsearch (line 189)
fv(:,1) = funfcn(x,varargin{:});
Error in CalibrationASM1_Namoniacal (line 11)
[p,fval,exitflag,output]=fminsearch(@optASM1,[1,1],options)
Below the way I put my equation and inputs in matlab:
% Load parameters for ASM1 first
%% Variable input
t=xlsread('Resultados experimentais.xlsx','N amoniacal','l7:l16');
Dexp=xlsread('Resultados experimentais.xlsx','N amoniacal','m7:m16');
global yh;
global ya;
global bh;
global ba;
%% Optimization
options=optimset('MaxFunEvals',400,'TolFun',1e-8,'TolX',1e-6);
[p,fval,exitflag,output]=fminsearch(@optASM1,[1,1],options)
%% Outputs
sim('ASM1_batelada');
Dsim=Snhout([2 25 41 49 67 77 83 86 90 92])
yh
ya
bh
ba
cc=corrcoef(Dexp,Dsim);
r2=cc(2,1)
And my functions is written in another file optASM1, as follows:
function f=optASM1(p)
Dexp=xlsread('Resultados experimentais.xlsx','N amoniacal','l7:l16');
texp=xlsread('Resultados experimentais.xlsx','N amoniacal','m7:m16');
global yh;
global ya;
global bh;
global ba;
yh=p(1);
ya=p(2);
bh=p(3);
ba=p(4);
%% Simulink
sim('ASM1_batelada');
Dsim=Snhout([2 25 41 49 67 77 83 86 90 92])
%% Cost-function
f=sum((Dexp-Dsim).^2)
Please, need help to solve this problem.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Simulink Environment Customization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!