plot the probability distribution from Schrodinger Equation

조회 수: 11(최근 30일)
Hasan Al Tarify 2021년 10월 10일
답변: Star Strider 2021년 10월 11일
Hi everyone,
I have been trying t plot this probability of a function in 3D space with the following coding, but it always gives a blank plot. I'll appriciate your help.
The function is:
f(x,y,z) = 8*sqrt(sin(k*x)*sin(k*y)*sin(k*z)) on the interval: 0<x<1, 0<y<1, and 0<z<1. Note that k = n*pi/a, in this case a =1 and n = 1.
>> n=1; a=1;
>> x = linspace(0,0.01,1);
>> y = linspace(0,0.01,1);
>> z = linspace(0,0.01,1);
>> [X,Y,Z] = meshgrid(x,y,z);
>> f = 8.*sqrt(sin(n*pi*x/a).*sin(n*pi*y/a).*sin(n*pi*z/a));
>> figure
>> scatter3(f,X,Y,Z)

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

채택된 답변

Star Strider 2021년 10월 11일
It gives a blank plot because the linspace calls are only producing one element. The third argument to linspace is the number of elements desired in the vector it produces. An argument of 1 returns the beginning point (first argument) and stops.
I am not certain what the desired result is, however here are two possibilities —
n=1; a=1;
x = linspace(0,0.01,25);
y = linspace(0,0.01,25);
z = linspace(0,0.01,25);
[X,Y,Z] = meshgrid(x,y,z);
f = @(x,y,z) 8.*sqrt(sin(n.*pi.*x/a).*sin(n.*pi.*y/a).*sin(n.*pi.*z/a));
figure
scatter3(X(:),Y(:),f(X(:),Y(:),Z(:)), '.')
figure
isosurface(X,Y,Z,f(X,Y,Z), 5E-13)
grid on
view(60,30)
I leave the rest to you.
.

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

추가 답변(2개)

Paul 2021년 10월 10일
scatter3() is used to plot points in 3D space. But f is really a function of three variables, so you'll need an alternative to visualize f. Check the doc page for visualizing volume data.
댓글 수: 0표시숨기기 이전 댓글 수: -1

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

VBBV 2021년 10월 11일
편집: VBBV 2021년 10월 11일
n=1; a=1;
x = linspace(0,0.01,10); % change the number of points to 10
y = linspace(0,0.01,10);
z = linspace(0,0.01,10);
%[X,Y,Z] = meshgrid(x,y,z);
f = 8.*sqrt(sin(n*pi*x/a).*sin(n*pi*y/a).*sin(n*pi*z/a));
figure
scatter3(x,y,f,'filled')
Meshgrid may not be necessary in your code, if you want to use scatter3 function,

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

Community Treasure Hunt

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

Start Hunting!

Translated by