Please Help!!! I know I'm making a really dumb mistake somewhere. I never have problems fitting data with lsqcurvefit except for this function.
I'm trying to fit the function: Jcur = x(3).*exp(-x(2)/T).*exp(-(1/x(1)).*integral(exp(-x(2)/T'),dT', from some constant to T)
so my limits of integration depend on the variable T
I use lsqcurvefit(@tsdcfit,x0,T,J,[],[],options)
and have a separate function file tsdcfit with my fitting variables and T:
function Jcur = tsdcfit(x,T); global k e r;
function fux = fun(x,T) range = 50:0.01:T; ex = exp(-x(2)/(range)); fux = trapz(range,ex); end
Jcur = x(3).*exp(-x(2)/T).*exp(-(1/x(1)).*fun(x,T)); end
Any help would be greatly appreciated! I know there's something wrong with how i call the function fun(x,T), I've played around with it a lot and it's basically only spitting out one value regardless of the range of T