function z = zernpol(n,m,r,nflag) [d="94Ab
%ZERNPOL Radial Zernike polynomials of order N and frequency M. Z1j3 F
% Z = ZERNPOL(N,M,R) returns the radial Zernike polynomials of Gni<@;}
% order N and frequency M, evaluated at R. N is a vector of I
f9t^T#
% positive integers (including 0), and M is a vector with the +an.z3?w
% same number of elements as N. Each element k of M must be a 5c?1JH62o8
% positive integer, with possible values M(k) = 0,2,4,...,N(k) \W5fcxf
% for N(k) even, and M(k) = 1,3,5,...,N(k) for N(k) odd. R is ZTV|rzE
% a vector of numbers between 0 and 1. The output Z is a matrix ml=tS,
% with one column for every (N,M) pair, and one row for every s)HLFdis@
% element in R. E"p;
% 5 rpX"(
% Z = ZERNPOL(N,M,R,'norm') returns the normalized Zernike poly- z:B4
% nomials. The normalization factor Nnm = sqrt(2*(n+1)) is P !:LAb(
% chosen so that the integral of (r * [Znm(r)]^2) from r=0 to @ i$jyc
% r=1 is unity. For the non-normalized polynomials, Znm(r=1)=1 =aM(r6 C
% for all [n,m]. ~Rx:X4|H
% ^8p=g-U\
% The radial Zernike polynomials are the radial portion of the qV^Z@N+,
% Zernike functions, which are an orthogonal basis on the unit &S/@i|_
% circle. The series representation of the radial Zernike 906b=
% polynomials is nCF1i2*6|"
% tOx)t$ix
% (n-m)/2 tz#Fy?pe
% __ 9sQ7wlK
% m \ s n-2s 5;{Q >n
% Z(r) = /__ (-1) [(n-s)!/(s!((n-m)/2-s)!((n+m)/2-s)!)] * r R
pUq#Y:a
% n s=0 [=dK%7v
% G:'hT=8
% The following table shows the first 12 polynomials. 9os>k*
% 9V5}%4k%+
% n m Zernike polynomial Normalization ,,_$r7H`
% --------------------------------------------- R-Y07A
% 0 0 1 sqrt(2) S>AM?
% 1 1 r 2 EqW/Wxv7b
% 2 0 2*r^2 - 1 sqrt(6) b 4o`eR
% 2 2 r^2 sqrt(6) i,5mH$a&u:
% 3 1 3*r^3 - 2*r sqrt(8) WCc7 MK
% 3 3 r^3 sqrt(8) .xnJT2uu'
% 4 0 6*r^4 - 6*r^2 + 1 sqrt(10) 9?8Yf(MC%u
% 4 2 4*r^4 - 3*r^2 sqrt(10) Gt>*y.]
% 4 4 r^4 sqrt(10) cB,O"-
% 5 1 10*r^5 - 12*r^3 + 3*r sqrt(12) HE>6A|rgDr
% 5 3 5*r^5 - 4*r^3 sqrt(12) kzq3-NTV
% 5 5 r^5 sqrt(12) Uy$1X
% --------------------------------------------- -:mT8'.F-
% WvV!F?uqZ
% Example: |Nx7jGd:i
% KxZup\\:v
% % Display three example Zernike radial polynomials 0$8iWL
% r = 0:0.01:1; "UUzLa_
% n = [3 2 5]; $\:;N]Cs~0
% m = [1 2 1]; Fp3NWvu
% z = zernpol(n,m,r); lOk'stLNa&
% figure %kB84dE
% plot(r,z) AmSrc.
% grid on 2y"]rUS`
% legend('Z_3^1(r)','Z_2^2(r)','Z_5^1(r)','Location','NorthWest') O7&