Solve and graph a cubic equation with parameter

7 次查看(过去 30 天)
Hi everyone,
I am pretty new with matlab, and right now I am a bit lost. I want to solve the following cubic equation:
-16x^3 + (14-2w)x^2 - (4/3)x - (w/9 + 5/27) = 0
w is a parameter between 0 and 1. I only want the solutions where x is between 0 and 1. What I would like is to plot x when w varies between 0 and 1, let's say starting from 0 and increasing by 0.1.
I have found that roots can solve the function for me, but I am not sure how to get a graph out of it.
Help would be much appreciated!

回答(1 个)

John D'Errico
John D'Errico 2016-2-1
编辑:John D'Errico 2020-11-24
Easy, peasy. However, I would not use roots for that, as it will not allow you to distinguish the various roots as they cross paths. As well, it will force you to do the solves in a loop.
syms x w
x_w = solve(-16*x^3 + (14-2*w)*x^2 - (4/3)*x - (w/9 + 5/27) == 0,x,'maxdegree',3);
ezplot(vpa(x_w(1)),[0,1])
ezplot(vpa(x_w(2)),[0,1])
ezplot(vpa(x_w(3)),[0,1])
I won't actually include the graphs here though.
I would point out that you need to remember to use * when you multiply. That is, 2w is not a valid MATLAB expression.

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by