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!