problem plotting 3d function
2 views (last 30 days)
Show older comments
Elinor Ginzburg
on 23 May 2021
Commented: Sulaymon Eshkabilov
on 23 May 2021
Hello,
I'm trying to plot a 3-d function. I saw there are many questions about it, but I didn't found the answer I needed. I'm trying to plot the following function: where ,
and also ,
unfortunately, in the plot I get, my function is constant in ϕ which is weird since it is affected by it. I think I defined my axis in a wrong way. perhaps anyone has an idea what could be the problem? here's my code:
% set parameters
theta = linspace(0,pi);
phi = linspace(0,2*pi);
delta = ( (sin(theta).^2) .* sqrt(1 - 2 .* cos(2*phi) .* ((cot(theta)).^2) + ((cot(theta)).^4) ) );
eig1 = 0.5.*(1+delta);
eig2 = 0.5.*(1-delta);
% entanglement entropy function
Eentropy = -(eig1.*log(eig1) + eig2.*log(eig2));
% reshape vector into matrix to fit data size for surf() function. X,Y
% vectors are 100x100 where Eentropy is 1x100 thus need to replicate it 100
% times as rows and 1 time as column
Eentropy = repmat(Eentropy,100,1);
% draw surface and add axis titles
surf(Eentropy);
xlabel("\phi [rad]");
ylabel("\theta [rad]");
zlabel("z axis");
title("Entanglement Entropy");
and here's the plot:
Thank you very much for your help!
0 Comments
Accepted Answer
Sulaymon Eshkabilov
on 23 May 2021
Hi
Here is the corrrected code.
theta = linspace(0,pi);
phi = linspace(0,2*pi);
[theta, phi]=meshgrid(theta, phi);
delta = ( (sin(theta).^2) .* sqrt(1 - 2 .* cos(2*phi) .* ((cot(theta)).^2) + ((cot(theta)).^4) ) );
eig1 = 0.5*(1+delta);
eig2 = 0.5*(1-delta);
% entanglement entropy function
Entropy = -(eig1.*log(eig1) + eig2.*log(eig2));
surf(phi, theta, Entropy);
xlabel("\phi [rad]");
ylabel("\theta [rad]");
zlabel("z axis");
title("Entanglement Entropy");
2 Comments
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!