Multiple parameters optimization having calculated and experimental values
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Torsten
2018년 9월 7일
편집: Torsten
2018년 9월 7일
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
Torsten
2018년 9월 11일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!