How to choose the real root in z^3

I would like to know how matlab choose real root in solving non-linear equation. example, z^3=8, as we know there will be pair of complex roots and 1 real roots that is 2. So, how the matlab choose the real root, as we ignore the complex root. If we are plotting graph, we get complex roots and real roots at the same time. When i plot the graph, the graph will stop when the roots go to complex. So, is there any command to differentiate real root and complex root, as we juz nid the real root to plot graph

Answers (1)

variant 1
x = sym('x','real'); % or: syms x real
xreal = solve(x^3-8,x)
variant 2
x = sym('x','unreal'); % or: syms x unreal
x = solve(x^3-8,x);
xreal = x(imag(x) == 0)

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 27 Apr 2011

Community Treasure Hunt

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

Start Hunting!