problem plotting 3d function
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!