function VAN=van_spharm_s2(deg,z,phi)

% create a vandermonde matrix of spherical harmonics at the points (z,phi)
% where we are using the cylindrical coordinates on the sphere that is
% x=cos(phi)*sqrt(1-z^2)
% y=sin(phi)*sqrt(1-z^2)
% z=z
%
% programs not usually lie in standard Matlab versions
% spharmrd
% from Paul Leopardi
% plkd (in spharmrd)
% from Paul Leopardi

cont=0;
for i=0:1:deg
    [VAN(cont+1:cont+2*i+1,:)]=spharmrd(i,z,phi);
    cont=cont+2*i+1;
end
VAN=VAN';