Curve fitting with complexe custom function
1 view (last 30 days)
Show older comments
I want to fit some experimental data to a custom equation of this type:
Where a(T) and c(T) are some complicated functions of T (T is my x-axis parameter).
I calculate a(T) from a for loop. In my code a(T) and c(T) are represented by preExpPu(i,j,k) and preExpU(i,j,k). So basically the equation from the Figure above is my equation represented in the for loop by condTot(i,j,k). I know the values of a(T) and c(T) because I have calculated them. However, what I would like to fit is the values of b and d.... (in the exponential functions). The difficult part is that a(T) and c(T) are functions of T so I could not fit the whole data to a function of a type (a/T) exp(-b/T) + (c/T) exp(-d/T) because a and b are simply not constants, by vary with T... Is there any way to fit directly in the for loop do get the values of b and d?
for i=1:numel(T)
for j=1:numel(x)
for k=1:numel(y)
K(i)=exp((-H/(k1*T(i)))+1);
%Calcul de la fréquence moyenne des phonons (s-1)
v(j,k)=((2*pi*k2)/h)*TempDeb(j,k);
%Calcul des concentrations en trous/electrons
p(i,j,k)=-x(j)+(K(i)-sqrt(4*K(i)*x(j)*(K(i)*(x(j)-2*y(k)+1)+2*(y(k)-x(j))-1)+4*K(i)*y(k)*((y(k)-1)*(K(i)-1))+(K(i)^2)+4*(x(j)^2)))/(2*(K(i)-1));
n(i,j,k)=p(i,j,k)+2*x(j);
% % %Calcul des conductivité électriques dues à Pu et à U (S/m)
preExpPu(i,j,k)=(((4*(e^2)*v(j,k))/(a(j,k)*k2))*((n(i,j,k))/(y(k)))*(1-((n(i,j,k))/(y(k)))));
preExpU(i,j,k)=(((4*(e^2)*v(j,k))/(a(j,k)*k2))*((p(i,j,k))/(1-y(k)))*(1-((p(i,j,k))/(1-y(k)))));
condPu(i,j,k)= (preExpPu(i,j,k))/(T(:,i))*exp(-c/(k1*(T(:,i))));
condU(i,j,k)= (preExpU(i,j,k))/(T(:,i))*exp(-d/(k1*(T(:,i))));
% % %Calcul de la conductivité électrique totale (S/m)
condTot(i,j,k)=condPu(i,j,k)+condU(i,j,k);
end
end
end
2 Comments
Mathieu NOE
on 29 Jun 2021
hello
maybe you should share some data wit a working code so we can (try) help you better
Answers (0)
See Also
Categories
Find more on Statics and Dynamics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!