资源简介
泽尼克多项式前36项matlab代码,改其中参数可实现前N项拟合,或看第K项波前
代码片段和文件信息
clc;
clear all;
format long
%R0;被测镜半径
%Dia;被测镜口径
Dia=10;
x_Number=401;%x方向采样数
y_Number=x_Number;%y方向采样数
%qiu_o=[00-R0];球心坐标
%H0=(R0^2-(Dia/2)^2)^0.5;
%% 在被测镜面上生成点阵
%[x_lensy_lens]=meshgrid(-Dia/2:Dia/(x_Number-1):Dia/2Dia/2:-Dia/(y_Number-1):-Dia/2);
%for i=1:1:x_Number;
%for j=1:1:y_Number;
% if (x_lens(ij)^2+y_lens(ij)^2)^0.5>Dia/2
% x_lens(ij)=NaN;
% y_lens(ij)=NaN;
% end
% end
%end
[x_lensy_lens] = meshgrid(-1:0.01:1-1:0.01:1);
x=x_lens;
y=y_lens;
WF = zeros(size(x))+nan;
dzdx = zeros(size(x))+nan;
dzdy = zeros(size(x))+nan;
ind = find(x.^2+y.^2 <= 1);
x1 = x(ind);
y1 = y(ind);
Cc(1:36)=1;
%Cc(1)=1;Cc(2)=1;Cc(3)=1;Cc(4)=1;Cc(5)=1;Cc(6)=1;Cc(7)=1;Cc(8)=1;Cc(9)=1;Cc(10)=1;Cc(11)=1;Cc(12)=1;
z_fitting=Cc(1)*x+...
Cc(2)*y+...
Cc(3)*(2*x.^2+2*y.^2-1)+...
Cc(4)*(x.^2-y.^2)+...
Cc(5)*2*x.*y+...
Cc(6)*(3*x.^3+3*x.*y.^2-2*x)+...
Cc(7)*(3*x.^ 2.*y+3*y.^3-2*y)+...
Cc(8)*(6*x.^4-6*x.^2+1)+...
Cc(9)*(x.^3-3*x.*y.^2)+...
Cc(10)*(3*x.^2.*y-y.^3)+...
Cc(11)*(4*x.^4-3*x.^2+3*y.^2-4*y.^4)+...
Cc(12)*(8*x.^3.*y+8*x.*y.^3-6*x.*y)+...
Cc(13)*(10*x.^5+20*x.^3.*y.^2+10*x.*y.^4-12*x.^3-12*x.*y.^2+3*x)+...
Cc(14)*(10*x.^4.*y+20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