Error : Objective function is returning undefined values at initial point. lsqcurvefit cannot continue
Mostrar comentarios más antiguos
I am having this ''Objective function is returning undefined values at initial point. lsqcurvefit cannot continue'' errror message from the code. Not sure what I should change. Please let me know your suggestions. I have attached the experimental data file as well.
clear all, close all, clc
EQEACRXTN = xlsread('EQEACRXTN','Sheet1','A21:B53');% loading raw data from excel file
CurrentData = EQEACRXTN(:,1);
EQEData = EQEACRXTN(:,2);
%parameter estimation (units per ns)
B0 = [1e-10,1e-15]; %sequence [k_rs,k_ISC,k_RISC,k_NRT,k_SS,k_ST,k_TT] ]
lb = [1e-10,1e-15];% lower bound estimation
ub = [10e-10,5e-15];% upper bound estimation
options = optimset('Algorithm', 'trust-region-reflective');
[B,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@fitEQE,B0,CurrentData,EQEData,lb,ub,options);%sending data for fitting
F = fitEQE(B,CurrentData);% fitted data saving
figure(1)
plot(CurrentData,EQEData,'bo')%raw data
hold on
plot(CurrentData,F,'r','linewidth',2)%fit data 4.6
% grid on
% grid minor
xlabel('Current Density (mA/cm^2)');
ylabel('EQE (%)');
legend('Experimental EQE','EQE fit');
set(gca,'xscale','log')
set(gca,'yscale','log')
%
function nEQE = fitEQE(B,CurrentData)
% % % NonLinear Part
syms Ns Nt
assume(Ns > 0);
assume(Nt > 0);
k_rs = 1.1000e-02*1e9;
k_ISC = 8.7545e-03*1e9;
k_RISC = 9.9000e-04*1e9;
k_NRT = 1.9998e-04*1e9;
d = 15e-7 ;
e = 1.6e-19*1e3 ;
J = CurrentData.';
sol_Ns = double((nan(numel(J),1)));
sol_Nt = double((nan(numel(J),1)));
for i = 1:numel(J)
eq1 = -(k_rs+k_ISC)*Ns+k_RISC*Nt-B(1)*Ns*Nt+0.25*B(2)*Nt.^2+(J(i)/(4*d*e))==0 ;
eq2 = k_ISC*Ns-(k_RISC+k_NRT)*Nt-1.25*B(2)*Nt.^2+((3*J(i))/(4*d*e))==0 ;
[sol_Ns(i),sol_Nt(i)] = vpasolve([eq1, eq2],[Ns,Nt]);
end
%linear Part
syms Ns0 Nt0
assume(Ns0 > 0);
assume(Nt0 > 0);
% nlinear1 =0;
% nlinear2 = 0;
Singlet = double((nan(numel(J),1)));
Triplet = double((nan(numel(J),1)));
for ii = 1:numel(J)
nlinear1 =-(k_rs+k_ISC)*Ns0+k_RISC*Nt0+(J(ii)/(4*d*e));
nlinear2 = k_ISC*Ns0-(k_RISC+k_NRT)*Nt0+((3*J(ii))/(4*d*e));
[Singlet(ii),Triplet(ii)] = solve([nlinear1,nlinear2],[Ns0,Nt0]);
end
% % % EQE predition
nEQE0 = 3.8;
nEQE = nEQE0*(sol_Ns./Singlet);
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Calculus en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!