How do write a while loop for a function m file that takes the input of a function handle?

1 回表示 (過去 30 日間)
I have to create a function me file called myfirstzero(f,a) which takes two inputs:
f: A function handle which you may assume will represent a polynomial.
a: A real number.
Does: Uses a while loop to find the smallest n such f^(n)(a) = 0. Note that this means the nth derivative at x = a and note that n = 0 is fair game, where the 0th derivative of a function is just the function itself.
Returns: This value of n.
All I need is for somebody to help get me started writing this code. All I was able to write so far is:
function x=myfirstzero(f,a);
I just don't know what the while loop conditions are that need to be met to start the while loop. Or statements needed inside the while loop.

採用された回答

Star Strider
Star Strider 2014 年 9 月 14 日
編集済み: Star Strider 2014 年 9 月 14 日
You and Sea must be in the same class! How do I fix this error with function handle?
  2 件のコメント
Bri
Bri 2014 年 9 月 14 日
Thank you for directing me this post. However, I do not really understand your code, specifically I don't get why you chose to make the conditions the while loop must meet to be (d > 0) && (n < 6). If you could please explain your code to me that would be great.
Star Strider
Star Strider 2014 年 9 月 14 日
According to Sea’s description of the problem, the loop has to run while (d > 0) and not compute higher than the 6th derivative. The n counter counts the degree of the derivative.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by