problem plotting 3d function

조회 수: 2 (최근 30일)
Elinor Ginzburg
Elinor Ginzburg 2021년 5월 23일
댓글: Sulaymon Eshkabilov 2021년 5월 23일
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!

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 5월 23일
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
Elinor Ginzburg
Elinor Ginzburg 2021년 5월 23일
Thank you so much!
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 5월 23일
Most welcome! It is just a pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by