error: fzero: zero point is not bracketed
Afficher commentaires plus anciens
Hi. So this is what I wrote so far in octave:
syms x
f=4*x.^2+20*x+4
x=fzero(@(x) f, -5)
but I keep getting the error in the title. What is wrong with what I wrote? Thanks in advance!
Réponses (1)
Use fzero for numeric functions and solve for symbollic functions —
syms x
f=4*x.^2+20*x+4
x=vpa(solve(f==0))
format long
xd = double(x)
whos x xd
.
3 commentaires
Andreea Oana
le 5 Jan 2022
syms x
f=4*x.^2+20*x+4
F = matlabFunction(f)
x = fzero(F, -5)
or
f = @(x) 4*x.^2 + 20*x + 4
x = fzero(f, -5)
One approach —
syms x
f=4*x.^2+20*x+4
f_fcn = matlabFunction(f)
format long
x=fzero(f_fcn,-5)
To get the other root, use a different initial parameter estimate —
x=fzero(f_fcn,-1)
.
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
