MATLAB: How do i solve a cubic function giving the answer in a matrix

subs

Im trying to solve this cubic equation to give me the intersection points at Pr and give me the anser in a matrix format. Doing this only gives me one answer not three
Pr=input('Pr=');
solve(0==((8*0.9)/((8*Z)-1))-(27/(64*(Z^2)))-Pr,Z);
Z=subs(Z,Pr)

Best Answer

Try this:
syms Z
Pr = 42; % Choose A Number ...
Zs = solve(0==((8*0.9)/((8*Z)-1))-(27/(64*(Z^2)))-Pr,Z)
Zroots = vpa(Zs)
Zrootsd = double(Zroots)
produces:
Zs =
root(z^3 - (41*z^2)/280 + (9*z)/896 - 9/7168, z, 1)
root(z^3 - (41*z^2)/280 + (9*z)/896 - 9/7168, z, 2)
root(z^3 - (41*z^2)/280 + (9*z)/896 - 9/7168, z, 3)
Zroots =
0.0036611845692819380187451079457217 - 0.094934986290941940021998513244942i
0.0036611845692819380187451079457217 + 0.094934986290941940021998513244942i
0.13910620229000755253393835553713
Zrootsd =
0.00366118456928194 - 0.0949349862909419i
0.00366118456928194 + 0.0949349862909419i
0.139106202290008 + 0i
Related Question