Solving one equation with one unknown and get all possible solutions

6 ビュー (過去 30 日間)
Hassan Alkomy
Hassan Alkomy 2018 年 10 月 25 日
コメント済み: Hassan Alkomy 2019 年 1 月 8 日
I have an equation and I need to get its solution. I think it has more than one solution, but using the command (solve) I can get only one solution.
Actually, it is expected to get real and complex solutions, but I am interested on the real solutions only.
How can I get this solution in Matlab.
the required unknown is (alphap) and my equation and the command that I have used is:
m=15; Ki=1.3908e+06; B=0.945e-1; db=0.79e-2; alphao=.2618;
x = solve(Pr == m*Ki*(B*db*(cos(alphao)/cos(alphap)-1))^(3/2)*sin(alphap),alphap)
The answer is:
x = 0.37336926931567958392238007768557i
  3 件のコメント
Dimitris Kalogiros
Dimitris Kalogiros 2018 年 10 月 26 日
what is the value of Pr ?
Hassan Alkomy
Hassan Alkomy 2019 年 1 月 4 日
Pr=10

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

採用された回答

Stephan
Stephan 2019 年 1 月 4 日
編集済み: Stephan 2019 年 1 月 4 日
Hi,
getting all possible soultions is a hard job, because you have an infinite bunch of real solutions:
You find them for example by using fzero:
m=15;
Ki=1.3908e+06;
B=0.945e-1;
db=0.79e-2;
alphao=.2618;
Pr = 10;
format long
fun = @(alphap)Pr - m*Ki*(B*db*(cos(alphao)/cos(alphap)-1))^(3/2)*sin(alphap)
x1 = fzero(fun,0.5)
This code results in:
x1 =
0.542034560066698
If you want more solutions just add or subtract integer multiples of 2*pi. Then you can construct as many real solutions as you want by yourself:
x2 = fzero(fun,2*pi+x1)
is_it_2_pi = (x2-x1)/(2*pi)
gives:
x2 =
6.825219867246284
is_it_2_pi =
1
Best regards
Stephan
  5 件のコメント
Walter Roberson
Walter Roberson 2019 年 1 月 8 日
The way your problem is constructed, with the sin(alphap) and cos(alphap) you would expect the results to repeat exactly every 2 π radians, since sin(alphap + 2*pi) = sin(alphap) and cos(alphap + 2*pi) = cos(alphap) . In theory. In practice due to round-off error it does not hurt to use the +2*pi as the starting point and use fzero() to confirm the exact location to within numeric bounds.
Hassan Alkomy
Hassan Alkomy 2019 年 1 月 8 日
Thank you Walter. That makes sense. Thank you!

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

その他の回答 (1 件)

Vineeth Nair
Vineeth Nair 2018 年 10 月 30 日
編集済み: Vineeth Nair 2018 年 10 月 30 日
To get only real values use following command >>solve(equation, variable, 'Real', true)
You can read more about the solve function here .

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by