%%%%%%%%%%%%%%%%%%%%%%%%%
%  matlab script to visualize bessel functions of 
%  the first and second kind
%%%%%%%%%%%%%%%%%%%%%%%%%%
z=[0:.15:20]'; % set the vector z to go from 0-20
m=[0 1 2];  % set the order m to go from 0 to 2
j=zeros(length(z),length(m)); % initialize arrays for j and y
y=j;
for i=1:length(m)  % call the besselfunction routines
  j(:,i)=besselj(m(i),z);
  y(:,i)=bessely(m(i),z);
end

%
% and plot the whole mess out
%
figure;
subplot(2,1,1); plot(z,j(:,1),'-',z,j(:,2),'--',z,j(:,3),'-.','linewidth',[2]); 
grid; set(gca,'fontsize',[11],'fontweight','bold'); xlabel('z'); legend('J_0','J_1','J_2');
subplot(2,1,2);  plot(z,y(:,1),'-',z,y(:,2),'--',z,y(:,3),'-.','linewidth',[2]); 
grid;set(gca,'ylim',[-1 1],'fontsize',[11],'fontweight','bold');xlabel('z'); legend('Y_0','Y_1','Y_2');
print -depsc2 besselfuncc.eps