MATLAB: I have to construct a 3D plot and contour plot of the following equation which will result in rouge waves i have attached a pic of it .i have tried it several times but i am getting nothing.please help me with the task.any help would be appreciated

MATLABnls

syms X real;
syms T real;
syms z real
X=-12:12;
T=-2;2;
f=(192*exp(T*i)*(2*T^5*i + 5*T^4 + 4*T^3*X^2*i + T^3*i + 6*T^2*X^2 + (9*T^2)/2 + 2*T*X^4*i - 3*T*X^2*i - (15*T*i)/8 + X^4 + (3*X^2)/2 - 3/16));
g=(64*T^6 + 192*T^4*X^2 + 432*T^4 + 192*T^2*X^4 - 288*T^2*X^2 + 396*T^2 + 64*X^6 + 48*X^4 + 108*X^2 + 9);
h=f./g;
z=exp(T*i)-h;
ezsurf(z,[-2 2 -1.2 2])
zlim([0 1.8])

Best Answer

By converting the exp() into sin and cos, you can extract the imaginary part of z, getting
IMZ = sin(T)+(-192*sin(T)*(5*T^4+6*T^2*X^2+(9/2)*T^2+X^4+(3/2)*X^2-3/16)-192*cos(T)*(2*T^5+4*T^3*X^2+T^3+2*T*X^4-3*T*X^2-(15/8)*T))/(64*T^6+192*T^4*X^2+192*T^2*X^4+64*X^6+432*T^4-288*T^2*X^2+48*X^4+396*T^2+108*X^2+9)
In order to be able to plot z, this imaginary part IMZ must be 0.
You can attempt to solve IMZ for T, but there is no useful closed form solution for it.
You can solve IMZ for X, which will give you a set of 6 closed form solutions. For each of those, the expression is real valued for parts of the range T = -2 to +2; if there are real-valued solutions outside [-2, +2] then they would have to be quite close to the boundary (that is, the plots I did showed no obvious real solutions outside of [-2, +2] but my plots might not have been accurate enough to be sure.) One solution, for example, is
X = -(1/2)*(-tan(T)*(-48*tan(T)^3*T^4+72*tan(T)^3*T^2+192*tan(T)^2*T^3+3^(1/2)*(768*tan(T)^4*T^8-6912*tan(T)^4*T^6-6144*tan(T)^3*T^7-2016*tan(T)^4*T^4+9216*tan(T)^3*T^5+3072*tan(T)^2*T^6-2048*tan(T)*T^7-432*tan(T)^4*T^2+1152*tan(T)^3*T^3-4608*tan(T)^2*T^4+3072*tan(T)*T^5+2048*T^6-45*tan(T)^4-576*tan(T)^2*T^2+384*tan(T)*T^3-1536*T^4)^(1/2)*tan(T)+9*tan(T)^3+64*T^3)^(1/3)*(-(24*I)*3^(1/2)*tan(T)^2*T^2+I*(-48*tan(T)^3*T^4+72*tan(T)^3*T^2+192*tan(T)^2*T^3+3^(1/2)*(768*tan(T)^4*T^8-6912*tan(T)^4*T^6-6144*tan(T)^3*T^7-2016*tan(T)^4*T^4+9216*tan(T)^3*T^5+3072*tan(T)^2*T^6-2048*tan(T)*T^7-432*tan(T)^4*T^2+1152*tan(T)^3*T^3-4608*tan(T)^2*T^4+3072*tan(T)*T^5+2048*T^6-45*tan(T)^4-576*tan(T)^2*T^2+384*tan(T)*T^3-1536*T^4)^(1/2)*tan(T)+9*tan(T)^3+64*T^3)^(2/3)*3^(1/2)-(6*I)*3^(1/2)*tan(T)^2-(16*I)*3^(1/2)*T^2+4*(-48*tan(T)^3*T^4+72*tan(T)^3*T^2+192*tan(T)^2*T^3+3^(1/2)*(768*tan(T)^4*T^8-6912*tan(T)^4*T^6-6144*tan(T)^3*T^7-2016*tan(T)^4*T^4+9216*tan(T)^3*T^5+3072*tan(T)^2*T^6-2048*tan(T)*T^7-432*tan(T)^4*T^2+1152*tan(T)^3*T^3-4608*tan(T)^2*T^4+3072*tan(T)*T^5+2048*T^6-45*tan(T)^4-576*tan(T)^2*T^2+384*tan(T)*T^3-1536*T^4)^(1/2)*tan(T)+9*tan(T)^3+64*T^3)^(1/3)*tan(T)*T^2+24*tan(T)^2*T^2+(-48*tan(T)^3*T^4+72*tan(T)^3*T^2+192*tan(T)^2*T^3+3^(1/2)*(768*tan(T)^4*T^8-6912*tan(T)^4*T^6-6144*tan(T)^3*T^7-2016*tan(T)^4*T^4+9216*tan(T)^3*T^5+3072*tan(T)^2*T^6-2048*tan(T)*T^7-432*tan(T)^4*T^2+1152*tan(T)^3*T^3-4608*tan(T)^2*T^4+3072*tan(T)*T^5+2048*T^6-45*tan(T)^4-576*tan(T)^2*T^2+384*tan(T)*T^3-1536*T^4)^(1/2)*tan(T)+9*tan(T)^3+64*T^3)^(2/3)-3*tan(T)*(-48*tan(T)^3*T^4+72*tan(T)^3*T^2+192*tan(T)^2*T^3+3^(1/2)*(768*tan(T)^4*T^8-6912*tan(T)^4*T^6-6144*tan(T)^3*T^7-2016*tan(T)^4*T^4+9216*tan(T)^3*T^5+3072*tan(T)^2*T^6-2048*tan(T)*T^7-432*tan(T)^4*T^2+1152*tan(T)^3*T^3-4608*tan(T)^2*T^4+3072*tan(T)*T^5+2048*T^6-45*tan(T)^4-576*tan(T)^2*T^2+384*tan(T)*T^3-1536*T^4)^(1/2)*tan(T)+9*tan(T)^3+64*T^3)^(1/3)-8*(-48*tan(T)^3*T^4+72*tan(T)^3*T^2+192*tan(T)^2*T^3+3^(1/2)*(768*tan(T)^4*T^8-6912*tan(T)^4*T^6-6144*tan(T)^3*T^7-2016*tan(T)^4*T^4+9216*tan(T)^3*T^5+3072*tan(T)^2*T^6-2048*tan(T)*T^7-432*tan(T)^4*T^2+1152*tan(T)^3*T^3-4608*tan(T)^2*T^4+3072*tan(T)*T^5+2048*T^6-45*tan(T)^4-576*tan(T)^2*T^2+384*tan(T)*T^3-1536*T^4)^(1/2)*tan(T)+9*tan(T)^3+64*T^3)^(1/3)*T+6*tan(T)^2+16*T^2))^(1/2)/(tan(T)*(-48*tan(T)^3*T^4+72*tan(T)^3*T^2+192*tan(T)^2*T^3+3^(1/2)*(768*tan(T)^4*T^8-6912*tan(T)^4*T^6-6144*tan(T)^3*T^7-2016*tan(T)^4*T^4+9216*tan(T)^3*T^5+3072*tan(T)^2*T^6-2048*tan(T)*T^7-432*tan(T)^4*T^2+1152*tan(T)^3*T^3-4608*tan(T)^2*T^4+3072*tan(T)*T^5+2048*T^6-45*tan(T)^4-576*tan(T)^2*T^2+384*tan(T)*T^3-1536*T^4)^(1/2)*tan(T)+9*tan(T)^3+64*T^3)^(1/3))
It appears that for any given non-zero T value in [-2, +2], that there are either 2 or 4 X values at which the imaginary part of z disappears.
Therefore, like for your other question, there is no surface to draw: there are some lines of solution. If you were evaluating numerically, you would probably not happen to discover the lines of solution, so the entire plot would probably appear empty. You would need to do a symbolic solution and plot that.