请问最后的plot3怎么没画出图来,.。😭(画电子云图)


n=input('import the principal quantum number: ');
l=input('enter angle quantum number:');
colordef white;
a0=5.29e-11;
 i=25000;
 r=12*a0*rand(1,i);
 Nr=8/(n*a0)^3*factorial(n+l)/((factorial(n-l-1)*2*n)*factorial(2*l+1)*factorial(2*l+1));
 F=1;
for k=0:n-l
    F=F+(-1).^k*factorial(n-l-1)*factorial(2*l+1)*(2*r/(n*a0)).^k/(factorial(n-l-1-k)*factorial(2*l+1+k)*factorial(k));
end
 wr=Nr*exp(-r/(n*a0)).*(2*r/(n*a0)).^l.*F.^2;
 theta=pi*rand(1,i);
 phi=2*pi*rand(1,i);
 Y=legendre(l,sin(theta));
  for m=0:1;
     Nj=factorial(l-m)*(2*l+1)/(factorial(l+m)*4*pi);
     wj=Nj*Y(m+1,:).^2;
  end
 w=wr.*wj;wm=max(w(:));
 [x,y,z]=sph2cart(theta,phi,r);
 A=rand(1,i)*wm;
 subplot(1,1,1);
 axis([-0.5e-11 0.5e-11 -0.5e-11 0.5e-11 -0.5e-11 0.5e-11]);
 p=A<=w;
 plot3(x(p),y(p),z(p),'b.','MarkerSize',2);
 
   

 

有图像了!但是n,l值变化没有不同

你的:p=A<=w;而在工作区并没有发现p变量和它的值,说明p是空数组,也因为这导致x(p),y(p),z(p)为空,因此导致出现plot3输入参数不足的问题。p为空,则说明w中的元素都对应小于A的元素,你查看w和前面的值,看是否符合你的期望。

n=input('import the principal quantum number: ');
l=input('enter angle quantum number:');
a0=5.29e-11;
k=8000;
r=50*rand(1,k);
wr=hexishu(n,l,a0)*exp(-2*r/(n*a0)).(2*r/(n*a0)).^(2*l).*(heliuchao(n,l,2*r/(na0))).^2;
theta=pi*rand(1,k);
phi=2*pi*rand(1,k);
Y=legendre(l,sin(theta));
for m=0:l
Nj=factorial(l-m)*(2*l-1)/(factorial(l+m)*4*pi);
wj=Nj*Y(m+1,:).^2;
end
w=wr.*wj;
[x,y,z]=sph2cart(theta,phi,r);
A=rand(1,k);
subplot(1,1,1);
axis([-50 50 -50 50 -50 50]);
p=A<=w;
plot3(x(p),y(p),z(p),'r.');

最好这样贴代码,里面的hexishu函数和heliuchao函数最好提供一下,否则无法跑通

有没有报错或者运行日志什么的