Select one root of an second degree equation
古いコメントを表示
i have solved a second degree equation in matlab using the roots() command and i want only one root to be displayed. How do i do this in MATLAB? Thank you very much
採用された回答
その他の回答 (3 件)
Andrei Bobrov
2013 年 6 月 1 日
編集済み: Andrei Bobrov
2013 年 6 月 1 日
p = [3 -6 -7];
r = roots(p);
out = r(r>0);
2 件のコメント
Andrei Bobrov
2013 年 6 月 1 日
about positive root
Walter Roberson
2013 年 6 月 1 日
Caution: if there are imaginary roots, then only real() of the roots will be considered by the ">" operator. You might want to use
out = r(imag(r) == 0 & r > 0)
to select only positive real roots. If none exist then "out" will be empty.
カテゴリ
ヘルプ センター および File Exchange で Octave についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!