Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Error message using function fminunc
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, I'm using the function fminunc to find my least square error. Unfortunately I get the error message
Error using fminusub (line 16)
Objective function is undefined at initial point. Fminunc cannot continue.
Error in fminunc (line 457)
[x,FVAL,GRAD,HESSIAN,EXITFLAG,OUTPUT] = fminusub(funfcn,x, ...
I understand the error can be caused by an inf or nan value, however I don't this applicable to me (??). My program for generation born 1938 looks like (the other generations result in same error message):
fun_1938=@(param)f_Makeham(param, mu_perks_1938, 1938);
param0_1938 = [2.06441912000572E-07/1000,0.197642212387667/100000,1.23947876070978/10];
[param_1938, fval_1938]=fminunc(fun_1938,param0_1938);
where
function res = f_Makeham(param,mu_perks,year)
a0=param(1);
b0=param(2);
c0=param(3);
if year == 1938
x=(77.5:1:106.5)';
elseif year==1945
x=(70.5:1:106.5)';
elseif year==1955
x=(65.5:1:106.5)';
end
res=sum((a0+b0*exp(c0*x)-mu_perks).^2);
What is causing the error message? How can I error track this?
댓글 수: 1
답변 (1개)
Alan Weiss
2018년 4월 11일
The error is clear. Try to evaluate fun_1938(param0_1938) and you will find that it throws an error. Investigate the error using standard MATLAB debugging.
Alan Weiss
MATLAB mathematical toolbox documentation
댓글 수: 1
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!