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.

 채택된 답변

Oleg Komarov
Oleg Komarov 2012년 1월 6일

0 개 추천

fsolve(@(x) (2*x+4)/(x+2)-5,0)
And the equation you propose has no solution because x+2 simplifies away

댓글 수: 2

denis
denis 2012년 1월 6일
thanks, but whats the syntax for solve a valid equation?
Oleg Komarov
Oleg Komarov 2012년 1월 6일
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

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 6일

0 개 추천

If you have the symbolic toolbox, use solve() instead of fsolve()
solve('(2x+4)/(x+2)=5','x')

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

질문:

2012년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by