how solve 1 unknown varible function?

hi, i am new at matlab and i am having troubles with fsolve.
>> fsolve('(2x+4)/(x+2)=5','x') ??? Error using ==> fsolve at 148 FSOLVE only accepts inputs of data type double.

 Respuesta aceptada

Oleg Komarov
Oleg Komarov el 6 de En. de 2012
fsolve(@(x) (2*x+4)/(x+2)-5,0)
And the equation you propose has no solution because x+2 simplifies away

2 comentarios

denis
denis el 6 de En. de 2012
thanks, but whats the syntax for solve a valid equation?
Oleg Komarov
Oleg Komarov el 6 de En. de 2012
As in the example, if you have x = 1, rewrite as:
@(x) x-1
Then:
fsolve(@(x) x-1, X0) for some initial value X0
NOTE: no apostrophes

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 6 de En. de 2012
If you have the symbolic toolbox, use solve() instead of fsolve()
solve('(2x+4)/(x+2)=5','x')

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 6 de En. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by