|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
clear all;
clc;
% parameter initialisation
lambda = 514e-9;
% beam width in the x and y direction
NA=1.23;
w0 =lambda/(pi*NA);
% distance to beam waist
z=0*pi*w0^2/lambda;
k=2*pi/lambda;
[gp] = FT_init_gauss_param(lambda,1,'w0',w0,'z',z);
% Size of grid defined as +-range
xrange=8e-7;
yrange=8e-7;
% number of points of the grid
xpoints=256;
ypoints=256;
% vector to address all x and y values
x=linspace(-xrange,xrange,xpoints);
y=linspace(-yrange,yrange,ypoints);
disp('----------------------------------------------------------------------------------------');
disp(sprintf('Example 1: linear spaced grid, %dx%d points,\n range x/(2w0x)=%g, y/(2w0y)=%g\n',...
xpoints,ypoints,xrange/w0,yrange/w0));
field=FT_LG_field(gp,0,1,x,y,[0,0,0])+FT_LG_field(gp,1,3,x,y,[0,0,0])+FT_LG_field(gp,2,5,x,y,[0,0,0])...
+FT_LG_field(gp,3,7,x,y,[0,0,0])+FT_LG_field(gp,4,9,x,y,[0,0,0]);
[X,Y]=meshgrid(x,y);
Z=sqrt(X.^2+Y.^2);
am=1-ones(256,256).*(Z>5e-7);
ang=angle(field);
ang=-( ang.*am); %初始相位
for p=1:5
for l=1:10
s=16e-3;
p1=0;p2=1;p3=2;p4=3;p5=4;
l1=1;l2=3;l3=5;l4=7;l5=9;
c=quad2d(quanzhongyinzi(x,y),-1.35e-3,1.35e-3,-1.35e-3,1.35e-3,'AbsTol',1e-8);
end
end
子程序是
% 自定义函数文件:quanzhongyinzi.m
function [LG22] = quanzhongyinzi(p,l,x,y)
% parameter initialisation
lambda = 514e-9;
% beam width in the x and y direction
NA=1.23;
w0 =lambda/(pi*NA);
% distance to beam waist
z=0*pi*w0^2/lambda;
k=2*pi/lambda;
[gp] = FT_init_gauss_param(lambda,1,'w0',w0,'z',z);
[field]=FT_LG_field(gp,p,l,x,y,[0,0,0]);
ang=angle(field);
LG1=conj(field);
LG2=exp(i*ang)*LG1;
LG22=matlabFunction(LG2,'file', 'quanzhongyinzi');
提示错误是
??? Input argument "x" is undefined.
Error in ==> quanzhongyinzi at 12
[field]=FT_LG_field(gp,p,l,x,y,[0,0,0]);
Error in ==> xiangweiban at 46
c=quad2d(quanzhongyinzi(x,y),-1.35e-3,1.35e-3,-1.35e-3,1.35e-3,'AbsTol',1e-8);
原因可能是那个函数有4个变量,而我只要对其中x和y做二重积分。希望高手可以指点下,谢谢! |
|