@Torsten I had typo in my integral, so I was getting the constant value. Actually the integral should be not over energy.
But now I am having some issue with the curve fitting. I am using lower and upper bound to restrict the values but I am getting following error.
Lower and upper bounds not supported with complex-valued initial
A=xlsread('Data');
xdata=1240./A(:,1);
ydata=A(:,2);
plot(xdata,ydata,'r.','markersize',30)
box on
energy=xdata;
Absorption=ydata;
options =optimoptions(@lsqcurvefit,'Algorithm','levenberg-marquardt',...
'StepTolerance',1e-19,'MaxFunctionEvaluations',1e10, ...
'MaxIterations',1e3);
lb=[0.03, 2.35, 0.02, 2];
ub=[0.09, 2.40, 0.05, 5];
var=[0.0429 2.3776 0.0207 2.902];
MI=lsqcurvefit(@modelE,var,energy,Absorption,lb,ub,options);
fitdata=modelE(MI,energy);
hold on
% plot(energy,modelE(var,energy),'co')
% plot(energy,exciton(var,energy),'m.','markersize',30)
% plot(energy, continum(var,energy),'k.')
plot(energy,fitdata,'ro')
plot(energy,exciton(MI,energy),'g.','markersize',30)
plot(energy, continum(MI,energy),'b.')
function alpha = modelE(var,energy)
alpha = continum(var,energy) + exciton(var,energy);
end
function x= exciton(var,energy)
x= 2.*var(1).*sech((energy-var(2)+var(1))./var(3))+...
0.125.*var(1).*sech((energy-var(2)+(var(1)./8))./var(3))+...
(2/27).*var(1).*sech((energy-var(2)+(var(1)./27))./var(3));
end
function y= cont(var,energy,x)
y=(sech((energy-x)./var(3))).*(1./(1-exp(-2.*pi.*sqrt(var(1)./(x-var(2)))))).*(1./(1-(var(4).*(x-var(2)))));
end
function z= continum(var,energy)
z = integral(@(x)cont(var,energy,x),2.25,200,'ArrayValued',true);
end