Point data into 3d Surface
显示 更早的评论
So im learning quantum mechanics and ive just decided to plot a solution to the Schrodinger equation for a Hydrogen atom. It has a plane that oscillates in Z space and the colour through each one of those oscillations represents the probability density. Here is my code to make that a bit clearer:
%declare
e=2.718281828;
xh=4;
yh=4;
zh=6;
resolution=0.1;
t=-zh;
[x,y]=meshgrid(-xh:resolution:xh, -yh:resolution:yh);
z=((x*y)-(x*y))+t;
s=2*zh/resolution;
%Function
while 1
for k=0:s;
z=((x*y)-(x*y))+t;
c=abs(0.977.*z.*e.^(-sqrt(x.^2.+y.^2.+z.^2)/2)).^2;
surf(x,y,z,c,'edgecolor','none');
axis([-xh,xh,-yh,yh,-zh,zh]);
caxis([0.1,0.5]);
drawnow
t=t+resolution;
end
for k=0:s;
z=((x*y)-(x*y))+t;
c=abs(0.977.*z.*e.^(-sqrt(x.^2.+y.^2.+z.^2)/2)).^2;
surf(x,y,z,c,'edgecolor','none');
axis([-xh,xh,-yh,yh,-zh,zh]);
caxis([0.1,0.5]);
drawnow
t=t-resolution;
end
end
I was wondering how i could turn those colours into a 3d object i can rotate around. i know it could be achieved by saying for example every point that is red can become a vertice on the 3d mesh, i just dont know how to start putting that into code.
please ask if you would like me to clarify any more because i feel as though this description of what i want is quite vague.
回答(1 个)
Star Strider
2014-6-22
Cool plot!
I suggest you experiment with scatter3. See Examples ‘> Vary Marker Color’ for what seems to be a relevant application.
Also, the exp function will calculate e for you. So you can calculate c as:
c=abs(0.977.*z.*exp(-sqrt(x.^2.+y.^2.+z.^2)/2)).^2;
It’s faster, and gives you full double precision.
7 个评论
Daniel Wray
2014-6-22
Star Strider
2014-6-22
I watched a bit of the video. The isosurface function and its friends may be what you want. They will give a solid surface rather than a probability ‘cloud’, but they may be closer than scatter3 to what’s in the video. You can use different markers (such as points) with scatter3. You don’t have to use the default circles, so that may still be an option.
Daniel Wray
2014-6-22
Star Strider
2014-6-22
My pleasure!
There are people here — several of whom are MATLAB employees — who can help with isosurface if you encounter any problems.
Daniel Wray
2014-6-23
编辑:Daniel Wray
2014-6-23
Star Strider
2014-6-23
I suggest experimenting with scatter3 in the interim. It’s easier to work with. All you need is a 3D matrix of points, and it seems you can readily do that with some minor changes in your code. Add subscripts to c and have it as a function of the meshgrid meshes you’ve already created. The bonus is that it would actually look like a probability space.
Daniel Wray
2014-6-23
类别
在 帮助中心 和 File Exchange 中查找有关 Scatter Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!