function z = zernpol(n,m,r,nflag) ri-b=|h2j
%ZERNPOL Radial Zernike polynomials of order N and frequency M. @_}P-h
% Z = ZERNPOL(N,M,R) returns the radial Zernike polynomials of G2:
agqL/
% order N and frequency M, evaluated at R. N is a vector of NyNXP_8
% positive integers (including 0), and M is a vector with the p9{mS7R9T
% same number of elements as N. Each element k of M must be a <x>Mo
% positive integer, with possible values M(k) = 0,2,4,...,N(k) =fFP5e ['
% for N(k) even, and M(k) = 1,3,5,...,N(k) for N(k) odd. R is d5:c^`
% a vector of numbers between 0 and 1. The output Z is a matrix IyG}H}
% with one column for every (N,M) pair, and one row for every > /caXvS
% element in R. i?^L/b`H
% J<jy2@"tXo
% Z = ZERNPOL(N,M,R,'norm') returns the normalized Zernike poly- n,WqyNt*
% nomials. The normalization factor Nnm = sqrt(2*(n+1)) is B
\2SH%\
% chosen so that the integral of (r * [Znm(r)]^2) from r=0 to ; kI134i=
% r=1 is unity. For the non-normalized polynomials, Znm(r=1)=1 >}6%#CAf
% for all [n,m]. 4
"'~NvO
% a<bwzX|.
% The radial Zernike polynomials are the radial portion of the u.xnO cOH!
% Zernike functions, which are an orthogonal basis on the unit ?^\|-Gr
% circle. The series representation of the radial Zernike /h|#J
% polynomials is ]Er$*7f
% -PR N:'T
% (n-m)/2 ~2-1 j
% __ nZYBE030
% m \ s n-2s </*6wpN
% Z(r) = /__ (-1) [(n-s)!/(s!((n-m)/2-s)!((n+m)/2-s)!)] * r kMN~Y
% n s=0 P( 8OQL:
% {9q4)R}G
% The following table shows the first 12 polynomials. |aq"#Ml)
% -6B4sZpzD
% n m Zernike polynomial Normalization r\^b(rNe
% --------------------------------------------- *(DV\. l`
% 0 0 1 sqrt(2) c9h6C
% 1 1 r 2 iGB}Il)
% 2 0 2*r^2 - 1 sqrt(6) $1`2kM5
% 2 2 r^2 sqrt(6) z-)O9PV
% 3 1 3*r^3 - 2*r sqrt(8) SO0PF|{\r
% 3 3 r^3 sqrt(8) g]0_5?i
% 4 0 6*r^4 - 6*r^2 + 1 sqrt(10) *gWwALGo5
% 4 2 4*r^4 - 3*r^2 sqrt(10) r*Ca}Z
% 4 4 r^4 sqrt(10) xU`p|(SS-
% 5 1 10*r^5 - 12*r^3 + 3*r sqrt(12) :"/d|i`T
% 5 3 5*r^5 - 4*r^3 sqrt(12) }&D32\
% 5 5 r^5 sqrt(12) #AQV(;r7@
% --------------------------------------------- Ds:'Lb
% oNF6<A(@$
% Example: Ig>(m49d
% }*]-jWt1J\
% % Display three example Zernike radial polynomials 1iF1GkLEq
% r = 0:0.01:1; ~Z'?LV<t
% n = [3 2 5]; 3h`f 6
% m = [1 2 1]; P~X2^bw
% z = zernpol(n,m,r); R4:b{ )=O
% figure S 30%)<W
% plot(r,z) |&i<bqLw:
% grid on t"oeQ*d%
% legend('Z_3^1(r)','Z_2^2(r)','Z_5^1(r)','Location','NorthWest') .%
% kE1TP]|
% See also ZERNFUN, ZERNFUN2. U&q