MATLAB: Plotting roots of a polynomial

plotvector

Can someone help me with how to plot the below code. I want to plot 'x' for several different inputs of 'Ta' My solution 'a' is 3 roots of a polynomial.
clc
clear all
syms v
syms T
Tc=96.15+273 %K
Pc=4990; %KPa
R=(8.314/86.47)
Ta=100
omega = 0.22082
b=(0.0778*R*Tc)/(Pc)
a=((0.45724*(R^2)*(Tc^2))/(Pc^2))*exp((2+0.836*Ta/Tc)*(1-(Ta/Tc)^(0.134+(0.508*omega)-(0.0467*omega^2))))
P=inline('((0.0961*T)/(v-5.5338e-04))- (1.6795e-10/((v*(v+5.5338e-04)+5.5338e-04*(v-5.5338e-04))))','T','v')
f1=diff(P(T,v),T)
g1=vpa(subs(f1,T,Ta))
f2=diff(P(T,v),v)
g2=vpa(subs(f2,T,Ta))
v=(g1/g2)*Ta
x=vpasolve(v)
end

Best Answer

  • syms v
    syms T
    Tc=96.15+273 %K
    Pc=4990; %KPa
    R=(8.314/86.47)
    Ta=100
    omega = 0.22082
    b=(0.0778*R*Tc)/(Pc)
    a=((0.45724*(R^2)*(Tc^2))/(Pc^2))*exp((2+0.836*Ta/Tc)*(1-(Ta/Tc)^(0.134+(0.508*omega)-(0.0467*omega^2))))
    P=inline('((0.0961*T)/(v-5.5338e-04))- (1.6795e-10/((v*(v+5.5338e-04)+5.5338e-04*(v-5.5338e-04))))','T','v')
    f1=diff(P(T,v),T)
    g1=vpa(subs(f1,T,Ta))
    f2=diff(P(T,v),v)
    g2=vpa(subs(f2,T,Ta))
    v=(g1/g2)*Ta
    T=vpasolve(v)
    vv=subs(v,v,T)
    plot(T,vv,'-or')