Thanks for the code! I have a question about the unit of the zernike polynomials generated by this code, is it in [number of waves] or [micrometer]?
Thanks again!
Comment only
10 Mar 2011
Zernike polynomials
Zernike polynomials and functions (orthogonal basis on the unit circle).
I was running into problems when using my fitted terms in another program: the same coefficients did not give the same surface.
I found the cause: the cosine and sine terms are inverted in zernfun. M>0 should be a cosine, while M<0 should be a sine.
I've corrected this, starting at line 193
if any(idx_pos)
z(:,idx_pos) = y(:,idx_pos).*cos(theta*m(idx_pos)');
end
if any(idx_neg)
z(:,idx_neg) = y(:,idx_neg).*sin(theta*-m(idx_neg)');
end
% note the required sign change "-m" in the sine term
Comment only
30 Aug 2010
Zernike polynomials
Zernike polynomials and functions (orthogonal basis on the unit circle).
Very great functions! But the normalization with the 'norm' - option seems to be wrong. I've changed in:
zernfun.m
% For the normalized polynomials the line 177:
y(:,j) = y(:,j)*sqrt((1+(m(j)~=0))*(n(j)+1)/pi);
% I have to replaced by:
if m(j)==0
y(:,j) = y(:,j)*sqrt((n(j)+1));
else
y(:,j) = y(:,j)*sqrt(2*(n(j)+1));
end
5
30 Mar 2010
Zernike polynomials
Zernike polynomials and functions (orthogonal basis on the unit circle).
I am still becoming accustomed to MATLAB. When I run the zernfun.m by itself without any modifications, I get this error
??? Input argument "n" is undefined.
Error in ==> zernfun at 88
if ( ~any(size(n)==1) ) || ( ~any(size(m)==1) ).
However, when I initialized n, m, r, & theta, I get this error
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> meshgrid
Does anybody have any thoughts about making zernfun.m to work? Any help would be greatly appreciated.
Comment only