Effacer les filtres
Effacer les filtres

Error using MATLAB fsolve function and not sure why.

1 vue (au cours des 30 derniers jours)
Hayden Herrick
Hayden Herrick le 23 Avr 2022
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.

Réponses (1)

Walter Roberson
Walter Roberson le 23 Avr 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 .

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by