sh = sph_elec(x,y,z,n)
0001 function sh = sph_elec(x,y,z,n); 0002 %sh = sph_elec(x,y,z,n) 0003 if size(x,1) ~= 1 0004 error('too many rows') 0005 end; 0006 [az,el,r] = cart2sph(x,y,z); 0007 el = (pi/2)*ones(size(el,1),size(el,2)) - el; 0008 ass = legendre(n,cos(el)); 0009 sh = zeros(2*n+1,size(el,2)); 0010 for i=-n:n 0011 if i >= 0 0012 sh(i+n+1,:) = ass(abs(i)+1,:).*cos(abs(i)*(az)); 0013 else 0014 sh(i+n+1,:) = ass(abs(i)+1,:).*sin(abs(i)*(az)); 0015 end; 0016 end;