3D Plotting in matlab

I have got a function after integration in Matlab, f($\theta$,$g$) which is a complex function. I would like to get 3D plot the this function with respect to $\theta$ and g, where $g$ positive integer runs from 0 and $\theta $ runs from 0 to $\pi$. The function is very large and complicated one. Pl hep me to plot this.

2 个评论

It is disappointing that you deleted the further discussion and contributions from the volunteers :(
@walter: ...I am really Sorry for my nonsense activities. Actually, I did not under stand what was acttally going on. I thought that as I asked you people so many times regarding my corrections and rectifications, so better to clear my all these garbage kind of thing so that some important and summary conversation remain. But I really didn't understand that it actually causes some harmful to you.
Sorry for my activities once again. Pl pardon me if possible.

请先登录,再进行评论。

 采纳的回答

I assume ‘complex’ just means complicated, and not a function with real an imaginary arguments or output. If it is actually complex in the mathematical sense, a slightly different procedure than that presented here would be necessary.
Try something like this:
theta = linspace(0, pi, 50);
g = linspace(0, 100, 50);
[Th,G] = ndgrid(theta, g);
F = f(Th,G);
figure
mesh(Th, G, F)
grid on
Make appropriate changes to get the result you want.

4 个评论

P Maity’s Answer moved here —
Actually I would like to plot I= i*
%% Matlab code.
e=[0;1];
g=[1;0];
%% Basis vector chosen
eg=kron(e,g);
ee=kron(e,e);
gg=kron(g,g);
ge=kron(g,e);
%% Energy
E1=sqrt((1+alpha^2/2+alpha/2*sqrt(alpha^2+4*sin(theta)^2)));
%% Coefficients to construct Psi
a1=sin(theta)*exp(-1i*phi);
c1=E1-cos(theta);
d1=alpha*(cos(theta)-E1)*exp(1i*phi)/(sin(theta)-(cos(theta)-E1)*((cos(theta)+E1)/sin(theta)));
b1=-(cos(theta)+E1)*exp(-1i*phi)*d1/sin(theta);
%% Normalization factor of the state vector psi
m1=sqrt(a1*ctranspose(a1)+c1*ctranspose(c1)+d1*ctranspose(d1)+b1*ctranspose(b1));
%% State vector psi itself
psi=1/m1*(a1*eg+b1*ee+c1*gg+d1*ge);
%% derrivative of the state vector w.r.t phi
dpsi=diff(psi,phi);
%% Inner product of two vector accondingly
r=dot(psi,dpsi);
%% Now I need to perform that integration of phi and make a 3d plot of that result with
theta and alpha , aplha is a real integer runs from 0 to ...and theta from 0 to pi.
I am not following what you’re doing in your code.
The result needs to be a function of θ andg. Then you can use the techniques I described to plot it.
What result are you expecting for theta = 0 leading to division by sin(0)?
%% Now I need to perform that integration of phi and make a 3d plot of that result with
theta and alpha , aplha is a real integer runs from 0 to ...and theta from 0 to pi.
The integration of phi? But phi is one of your input variables, not an output formula.
Which of your formulas is to be integrated with respect to what? What should be a long the two independent axes? As you indicate that alpha is an integer, it sounds as if alpha is not one of your independent variables.
Your r is complex valued. Are you looking to plot the real or the imaginary part or are you looking to plot the absolute value?

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by