Solve eqn and get real part of solution in MatLab R2011b

1 view (last 30 days)
I use MatLab R2011b and want to solve an eqn and get the real part of solution. This is the code:
...
s=solve(y);
...
And this is solution: s =
0.3971412063699492853956558622094
-0.8763850946630804323385057262195
- 0.13537805585343442652857506799495 - 0.83663803641655759940578883730279*i
- 0.13537805585343442652857506799495 + 0.83663803641655759940578883730279*i
As you can see "s" has two solutions are real (0.3971 and -0.87638) and two imaginary (with i). The real solution is needed. Which command can be used in this case? Give the example is helpful.

Accepted Answer

Walter Roberson
Walter Roberson on 9 Oct 2015
s(imag(s)==0)

More Answers (0)

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!