want to get only all positive real roots

48 ビュー (過去 30 日間)
mosab qteshat
mosab qteshat 2019 年 4 月 22 日
編集済み: Dokeun Hwang 2021 年 5 月 22 日
Compute all positive real roots of x^4 + 2*x^3 − 7*x^2 + 3 = 0.
I want to discard all the imaginary ones and keep only the positive real root only
Can someone please guide me on that???
  1 件のコメント
Steven Lord
Steven Lord 2019 年 4 月 22 日
Show us what you've written so far and we may be able to suggest how to modify your code to return the positive real roots.

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

回答 (1 件)

Raj
Raj 2019 年 4 月 23 日
編集済み: Raj 2019 年 4 月 23 日
Use this:
p=[1 2 -7 0 3] % Your Polynomial equation coefficients matrix
A=roots(p) % All roots of equation
B=A(A>=0) % Only positive real roots of equation
This will be a useful read.
  4 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 23 日
Looks like this particular equation has only real roots, two negative and two postive.
Dokeun Hwang
Dokeun Hwang 2021 年 5 月 22 日
編集済み: Dokeun Hwang 2021 年 5 月 22 日
The answer above gives all the real parts in the roots
So, it should be corrected as below
B=A(real(A)>0&imag(A)==0);
ref: https://kr.mathworks.com/matlabcentral/answers/89612-how-to-select-real-positive-number

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

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by