Separate Roots for a Quadratic Function

15 ビュー (過去 30 日間)
Whitney Blair
Whitney Blair 2021 年 2 月 11 日
コメント済み: Whitney Blair 2021 年 2 月 11 日
I am making a table of roots with different quadratic functions. I need to use the roots function, and cannot figure out how to seperate them into each cell.
Here is my code:
a=1, b=3, c=8^-14;
x1=(-b+sqrt(b^2-4*a*c))/(2*a);
x2=(-b-sqrt(b^2-4*a*c))/(2*a);
x3=(-b+sqrt(b^2-4*a*c))/(2*a);
x4=(-2*c)/(b-sqrt(b^2-4*a*c));
TypeofFunction={'Original Function'; 'Modified Function'};
Root1=[x1;x3];
Root2=[x2;x4];
T=table(TypeofFunction,Root1,Root2)
It makes this table:
TypeofFunction Root1 Root2
_____________________ _____________________ _________________
{'Original Function'} -7.57172102794357e-14 -2.99999999999992
{'Modified Function'} -7.57172102794357e-14 -3.00293255131965
I want to add a third row using:
roots([a,b,c])
ans =
-2.999999999999924
-0.000000000000076
I don't know how to separate the roots into the columns.
Thank you.
  2 件のコメント
James Tursa
James Tursa 2021 年 2 月 11 日
編集済み: James Tursa 2021 年 2 月 11 日
Please post the code you are currently using and we can suggest methods to use to get the output in a format you want.
Walter Roberson
Walter Roberson 2021 年 2 月 11 日
num2cell()?

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 11 日
r = roots([a, b, c])
Root1(3) = r(1);
  1 件のコメント
Whitney Blair
Whitney Blair 2021 年 2 月 11 日
Thank you

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by