Clear Filters
Clear Filters

Error using MATLAB fsolve function and not sure why.

1 view (last 30 days)
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.

Answers (1)

Walter Roberson
Walter Roberson on 23 Apr 2022
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 .

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!