Clear Filters
Clear Filters

Matlab symbolic cannot separate real from imaginary

5 views (last 30 days)
I am attempting to seperate a complex expression using Matlab's symbolic package.
I have some real V and r, and I know something about the relation between them (i.e., the square root of 9*V^2 - 4/3*V*sym('pi')*r^3 is complex). However, Matlab will not seperate the real and imaginary parts of the expression, even if I used "preferReal" in simplify().
syms V r
assume(V >= 0)
assumeAlso(V,'real')
assumeAlso(r >= 0)
assumeAlso(r,'real')
assumeAlso((9*V^2 - 12*V*sym('pi')*r^3) < 0) % criterion about the relation between V and r
eq = pi / 3 * h^3 - pi * r *h^2+V == 0;
sol = solve(eq, h, 'MaxDegree',3);
simplify(real(sol(1)),'Criterion','preferReal' ,'Steps', 200)
The output of this is,
So basically, the second term (with the complex number in the denominator) is left Re(complex), which is not very helpful.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!