Effacer les filtres
Effacer les filtres

problem plotting 3d function

2 vues (au cours des 30 derniers jours)
Elinor Ginzburg
Elinor Ginzburg le 23 Mai 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!

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 23 Mai 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 commentaires
Elinor Ginzburg
Elinor Ginzburg le 23 Mai 2021
Thank you so much!
Sulaymon Eshkabilov
Sulaymon Eshkabilov le 23 Mai 2021
Most welcome! It is just a pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by