Multiple parameters optimization having calculated and experimental values
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone, I have a function that have to predict Hc and I have the Hcexperimental values. What I need to do, is optimize the 6 parameters that are in the function; so that the relative deviation between the calculated and experimental values becomes the smallest possible. I don't know if I need fmin, lsqnonlin, lsqcurvefit... I also don't know if I need multiple function files (.M files) to accomplish this. So far I've writen this:
function Hc = myfunction( P_k, T_k, c, z, w, v, IFexp )
y=T_k;
q=length(P_k);
%Initial values for parameters
par1=0.1442;
par2=2.6388;
par3=2.2083;
par4=0.2168;
par5=0.2;
par6=0.4;
%Ecuations
a=1.28+55.*(1./P_k+0.04).*exp(50.22./(T_k+230));
g=0.4+2084.69.*(1./P_k-0.002).*exp((-986.95)./(T_k+230));
x=(g./a).*c;
Hc=par1.*(x.^par2).*(y.^par3).*(z.^par4).*exp(par5.*w).*exp
(par6.*v);
disp(Hc)
RD=(IFexp-IFc)./IFexp.*100;
disp(RD)
ARD=100*(sum(RD))/q;
disp(ARD)
end
If someone could explain it to me detailed or show me an example with a script or even modify the script if needed; I'd be really grateful.
0 commentaires
Réponse acceptée
Torsten
le 7 Sep 2018
Modifié(e) : Torsten
le 7 Sep 2018
function main
P_k = ...;
Hcexp = ...;
T_k = ...;
z = ...;
w = ...;
v = ...;
c = ...;
a = 1.28+55.*(1./P_k+0.04).*exp(50.22./(T_k+230));
g = 0.4+2084.69.*(1./P_k-0.002).*exp((-986.95)./(T_k+230));
x = (g./a).*c;
p0 = [0.1442;2.6388;2.2083;0.2168;0.2;0.4];
p = lsqnonlin(@(p)fun(p,x,T_k,z,w,v,Hcexp),p0)
end
function res = fun(p,x,y,z,w,v,Hcexp)
Hc = p(1).*x.^p(2).*y.^p(3).*z.^p(4).*exp(p(5).*w).*exp(p(6).*v);
res = (Hc-Hcexp)./Hcexp;
end
Best wishes
Torsten.
6 commentaires
Torsten
le 11 Sep 2018
Then the warning says that it does not make sense to fit six parameters if you have less than six data points Hcexp.
And this warning is justified.
Best wishes
Torsten.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!