필터 지우기
필터 지우기

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.

채택된 답변

Torsten
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
Eduardo Chacin
Eduardo Chacin 2018년 9월 10일
@Torsten sorry, I did write "ub" instead of "up", but it has the same warning "Cannot solve problems with fewer equations than variables and with bounds. An error will be issued for this case in a future release. Ignoring bounds, using Levenberg-Marquardt method. "
Torsten
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 CenterFile 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!

Translated by