フィルターのクリア

Help using subfunction to compute zeros of a function

1 回表示 (過去 30 日間)
Steven
Steven 2012 年 4 月 1 日
コメント済み: Krishant 2024 年 3 月 11 日
I need help with creating a function with a subfunction to compute the zeros of a problem over a certain interval.
For example: 3x^3 - 12x^2 - 33x + 80 over -10 < x < 10
I want to find the all the zeros for that interval but every function I try it doesn't work. Here's my code so far:
function yzero = findzeros(range)
fun=@testfun;
[yzero,value]=fzero(fun,range);
function fx = testfun(x)
fx=(3.*x.^3)-(12.*x.^2)-(33.*x)+80;
end
end*
This only get it to compute one zero though but I graphed it on my calculator and there are 3 zeros over the interval.
Please Help me with finding a function that works!
  2 件のコメント
Walter Roberson
Walter Roberson 2012 年 4 月 1 日
Duplicate is at http://www.mathworks.com/matlabcentral/answers/34133-finding-zeros-of-an-equation
Krishant
Krishant 2024 年 3 月 11 日
Use a primary function with a subfunction to compute the zeros of the function 3𝑥 3 − 12𝑥 2 − 33𝑥 + 80 over the range −10 ≤ 𝑥 ≤ 10.

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

回答 (1 件)

Taniadi
Taniadi 2012 年 4 月 1 日
you can use fzero or fsolve to solve the problemm but it is necessary that you change initial guess to get 3 roots.
  1 件のコメント
Steven
Steven 2012 年 4 月 1 日
any suggestions on how I can do this?

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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by