error: fzero: zero point is not bracketed
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Star Strider
am 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 Kommentare
Walter Roberson
am 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
am 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)
.
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!