What to change in code?

5 ビュー (過去 30 日間)
Steve
Steve 2011 年 10 月 10 日
Hello Experts,
Given the following code:
How to transform it to work with the full polynomial, not from a(1).
I really need someone to help me with this issue urgently.
Thanks in advance!
  3 件のコメント
bym
bym 2011 年 10 月 10 日
whats wrong with answers here? http://www.mathworks.com/matlabcentral/answers/17931-bairstow-method-to-find-polynomial-roots-matlab-code-problem
Steve
Steve 2011 年 10 月 10 日
Hello proecsm,
Thanks for commenting, I am going to publish the problem and what I have done, so please be so kind and help me.

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

回答 (1 件)

Wayne King
Wayne King 2011 年 10 月 10 日
Steve, I have the same question proecsm asks, what's wrong with the answer Walter and I gave you in your earlier post? If you want the roots of:
p(x) = 2*x^2+2*x+1
You can do that with
roots([2 2 1])
or using your function, simply divide through by 2 and don't include the leading 1.
[rts,it]=bairstow([1 1/2],2,1e-3);
As I read Walter's post that is exactly what he clearly explained to you. And I certainly tried to explain very much the same thing.
It seems to me that you're much better off learning to provide the correct input to the funtion you have instead of trying to modify it to accept the input you want to give it.
  1 件のコメント
Walter Roberson
Walter Roberson 2011 年 10 月 10 日
Yup, exactly.
if a(1) ~= 1; a = a ./ a(1); end
a = a(2:end);
The test for 1 is merely an optimization. You could just use
a = a(2:end) ./ a(1);

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by