error: fzero: zero point is not bracketed
8 vues (au cours des 30 derniers jours)
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!
0 commentaires
Réponses (1)
Star Strider
le 5 Jan 2022
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
Walter Roberson
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)
Star Strider
le 5 Jan 2022
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)
.
Voir également
Catégories
En savoir plus sur Assumptions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!