필터 지우기
필터 지우기

Error using MATLAB fsolve function and not sure why.

조회 수: 1 (최근 30일)
Hayden Herrick
Hayden Herrick 2022년 4월 23일
답변: Walter Roberson 2022년 4월 23일
Im having trouble with an error using the function fsolve for a system of equations.
f = @(x) [h*(Tinf-T1)+ep*sigma*Ts-ep*sigma*x(2)-x(1); x(1)*(1/rr+1/rc)-(x(2)-Ts); x(1)*r2-(x(3)-x(2)); x(1)*r3(x(4)-x(3))];
x = fsolve(f, [1 1 1 1]);
the error is
Error in Me603HW55 (line 43)
x = fsolve(f, [1 1 1 1]);
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.

답변 (1개)

Walter Roberson
Walter Roberson 2022년 4월 23일
x(1)*r3(x(4)-x(3)
That code tries to index r3 at location x(4)-x(3)
Remember, MATLAB has absolutely no implied multiplication. NAME(EXPRESSION) is always either array indexing or function invocation, and never means multiplication of the content of NAME by the EXPRESSION .

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by