I cannot figure out how to fix this error "Objective function is returning undefined values at initial point. fsolve cannot continue."

조회 수: 1 (최근 30일)
function dummyhw8
clc
x0=[1,1,1,0.02,0,02,0.02];
x=fsolve(@fcn,x0);
disp ('Velocities are the first three values. Whereas friction is last 3.');
disp(x);
function z=fcn(x)
z(1)=x(1)-(0.64*x(2))-(0.64*x(3)); % where x1=v1 x2=v2 and x3=v3
z(2)=40-(102*x(4)*x(1)^2)-(127*x(5)*x(2)^2); % where x4=f1 x5=f2 x6=f3
z(3)=60-(102*x(4)*x(1)^2)-(127*x(6)*x(3)^2);
z(4)=1/sqrt(x(4))+2.0*log10((4.5e-4/3.7)+2.81e-5/x(1)/sqrt(x(4)));
z(5)=1/sqrt(x(5))+2.0*log10((5.625e-4/3.7)+3.52e-5/x(2)/sqrt(x(5)));
z(6)=1/sqrt(x(6))+2.0*log10((5.625e-4/3.7)+3.52e-5/x(3)/sqrt(x(6)));
  댓글 수: 5
Dominic Riepenhoff
Dominic Riepenhoff 2021년 11월 28일
Yup that did it, thanks! Prof gave us those values to guess with, so it still does not make the most sense but it works now.
Thanks again!
Dominic Riepenhoff
Dominic Riepenhoff 2021년 11월 28일
Are there any ways (besides changing those values) to avoid this fsolve error, so that I could still use my initial guess values that are close to zero?

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2021년 11월 28일
편집: Matt J 2021년 11월 28일
I suspect you meant to have 6 values in x0 rather than 7.
x0=[1,1,1,0.02,0.02,0.02];

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by