function z = zernpol(n,m,r,nflag) }yrs6pQ
%ZERNPOL Radial Zernike polynomials of order N and frequency M. iNi1+sm
% Z = ZERNPOL(N,M,R) returns the radial Zernike polynomials of aw lq/
% order N and frequency M, evaluated at R. N is a vector of Jpp-3i.F#
% positive integers (including 0), and M is a vector with the ziO(`"v
% same number of elements as N. Each element k of M must be a C^'r>0
% positive integer, with possible values M(k) = 0,2,4,...,N(k) K\ B!tk
% for N(k) even, and M(k) = 1,3,5,...,N(k) for N(k) odd. R is !F~1+V>zP
% a vector of numbers between 0 and 1. The output Z is a matrix 0Qeda@J
% with one column for every (N,M) pair, and one row for every (DvGA I
% element in R. 5"3`ss<m
% or;VmU8$zb
% Z = ZERNPOL(N,M,R,'norm') returns the normalized Zernike poly- gU&+^e >
% nomials. The normalization factor Nnm = sqrt(2*(n+1)) is hTZ6@i/pS
% chosen so that the integral of (r * [Znm(r)]^2) from r=0 to +&f_k@+
% r=1 is unity. For the non-normalized polynomials, Znm(r=1)=1 N
GnE
% for all [n,m]. n{<@-6
% Cpd>xXZz&S
% The radial Zernike polynomials are the radial portion of the yr>J^Et%_
% Zernike functions, which are an orthogonal basis on the unit
E>*b,^J7g
% circle. The series representation of the radial Zernike `g(#~0R
% polynomials is KdHkX+-R
% UBQtD|m\
% (n-m)/2 \?e2qu/ C
% __ c"`HKfL
% m \ s n-2s qa~ju\jm.
% Z(r) = /__ (-1) [(n-s)!/(s!((n-m)/2-s)!((n+m)/2-s)!)] * r zN+jn
% n s=0 >yVrIko
% x?0(K=h,
% The following table shows the first 12 polynomials. u\xrC\Ka
% 0VR,I{<.{
% n m Zernike polynomial Normalization -Tuk.>i)
% --------------------------------------------- p'@z}T?F
% 0 0 1 sqrt(2) (1er?4
% 1 1 r 2 loq2+(
% 2 0 2*r^2 - 1 sqrt(6) KU+u.J
% 2 2 r^2 sqrt(6) E:\#Ur2
% 3 1 3*r^3 - 2*r sqrt(8) n.5M6i/~a
% 3 3 r^3 sqrt(8) *}(B"FSO
% 4 0 6*r^4 - 6*r^2 + 1 sqrt(10) h=YTgJ
% 4 2 4*r^4 - 3*r^2 sqrt(10) '{JMWNY
% 4 4 r^4 sqrt(10) Td^62D;
% 5 1 10*r^5 - 12*r^3 + 3*r sqrt(12) l_
x jsu
% 5 3 5*r^5 - 4*r^3 sqrt(12) d--6<_q
% 5 5 r^5 sqrt(12) :N<o<