Solving one equation with one unknown and get all possible solutions

조회 수: 34(최근 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

댓글을 달려면 로그인하십시오.

채택된 답변

Stephan 2019년 1월 4일
편집: Stephan 2019년 1월 4일
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:
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 =
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)
x2 =
is_it_2_pi =
Best regards
  댓글 수: 5
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 .

Community Treasure Hunt

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

Start Hunting!

Translated by