フィルターのクリア

error: fzero: zero point is not bracketed

6 ビュー (過去 30 日間)
Andreea Oana
Andreea Oana 2022 年 1 月 5 日
コメント済み: Star Strider 2022 年 1 月 5 日
Hi. So this is what I wrote so far in octave:
syms x
f=4*x.^2+20*x+4
f = 
x=fzero(@(x) f, -5)
Error using fzero (line 308)
Initial function value must be finite and real.
but I keep getting the error in the title. What is wrong with what I wrote? Thanks in advance!

回答 (1 件)

Star Strider
Star Strider 2022 年 1 月 5 日
Use fzero for numeric functions and solve for symbollic functions —
syms x
f=4*x.^2+20*x+4
f = 
x=vpa(solve(f==0))
x = 
format long
xd = double(x)
xd = 2×1
-4.791287847477920 -0.208712152522080
whos x xd
Name Size Bytes Class Attributes x 2x1 8 sym xd 2x1 16 double
.
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 1 月 5 日
syms x
f=4*x.^2+20*x+4
f = 
F = matlabFunction(f)
F = function_handle with value:
@(x)x.*2.0e+1+x.^2.*4.0+4.0
x = fzero(F, -5)
x = -4.7913
or
f = @(x) 4*x.^2 + 20*x + 4
f = function_handle with value:
@(x)4*x.^2+20*x+4
x = fzero(f, -5)
x = -4.7913
Star Strider
Star Strider 2022 年 1 月 5 日
One approach —
syms x
f=4*x.^2+20*x+4
f = 
f_fcn = matlabFunction(f)
f_fcn = function_handle with value:
@(x)x.*2.0e+1+x.^2.*4.0+4.0
format long
x=fzero(f_fcn,-5)
x =
-4.791287847477920
To get the other root, use a different initial parameter estimate —
x=fzero(f_fcn,-1)
x =
-0.208712152522080
See the documentation on matlabFunction for details.
.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by