Azzera filtri
Azzera filtri

problem plotting 3d function

2 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Particle & Nuclear Physics in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by