24小时热门版块排行榜    

查看: 3368  |  回复: 0

efish424

铁虫 (初入文坛)

[求助] (matlab)角谱法程序解释。。完全不懂。。求解释。。越清晰越好

function varargout = ASP( U1,z,dxy1,lambda,varargin )
%ASP Diffraction calculation by Angular Spectrum Propagation method
%  Syntax:
%  [U2,dxy2] = ASP(U1,z,dxy1,'PropertyName','PropertyValue',...)
%  [U2,...] = ASP(U1,z,dxy1,...)
%  ASP(U1,z,dxy1,...)
%
%  U1 is the wavefront of the object plane
%  U2 is the wavefront of the diffraction plane
%  U1 and U2 are all two-dimensional array
%  size of U1 and U2 are even
%  z is the distance between object plane and diffraction plane
%  dxy1 is the sampling distance of the object, dxy1=[dx1,dy1]
%  lambda is the wavelength of the laser
%
%  if there is no output, image on diffraction plane will be displayed
%  else, no image will be displayed
%
%  the origin of coordinates is at M/2+1,N/2+1
%
%--------------------------------------------------------------------------
%  PropertyName and PropertyValue:
%  
%  piz               {off} | t
%  pad the input array with zeros
%       off - do not pad
%       t - paste U1 to an all zeros array whose size is t*size(U1)
%
%  iiz               {off} | t
%  interpolate the input array with zeros
%       off - do not interpolate
%       t - interpolate t-1 points between every two points
%
%  pfz               {off} | t
%  pad the frequency array with zeros
%       off - do not pad
%       t - paste the frequency array(F) to an all zeros array whose
%           size is t*size(F)
%
%  FTmethod          {fourier} | b,FSN,f0
%  which method to be use to realize the fourier transform
%       fourier - traditional fourier transform using single fft
%       b,FSN,f0 - FAFS using 3 ffts, b,FSN,f0 are the parameters needed
%
%  IFTmethod         {invfourier} | b,SSN,xy0
%  which method to be use to realize the inverse fourier transform
%       invfourier - traditional inverse fourier transform using single fft
%       b,SSN,xy0 - IFASS using 3 ffts, b,SSN,xy0 are the parameters needed
%--------------------------------------------------------------------------
error(nargchk(4,14,nargin))
if nargout>2
    error('Too many output arguments')
end
for n=1:length(varargin)
    if ~ischar(varargin{n})
        error('Property names and values must be characters')
    end
end
%  ----------------------construct the property array----------------------
parray=[0,0,0,0,0];                                                         % initialize the property array, the property array
                                                                            % is used to store the property specified by the user
freepv={'1','1','1','',''};                                                 % initialize the free property value array, free property
                                                                            % values do not fall into those values in the property structure
property=struct('name',{'piz','iiz','pfz','FTmethod','IFTmethod'});         % construct the property structure,
property(1).value={'off',''};                                               % which stores all possible properties
property(2).value={'off',''};
property(3).value={'off',''};
property(4).value={'fourier',''};
property(5).value={'invfourier',''};
for l=1:2:length(varargin)
    namefound=0;
    valuefound=0;
    m=0;
    n=0;
    while ~namefound && m         m=m+1;
        if strcmp(varargin{l},property(m).name)
            namefound=1;
        end
    end
    while namefound && ~valuefound && n         n=n+1;
        if strcmp(varargin{l+1},property(m).value{n})
            valuefound=1;
            parray(m)=n;
        end
    end
    %----------------------------------------------
    if namefound==1 && valuefound==0
        parray(m)=3;
        freepv{m}=varargin{l+1};
        valuefound=1;
    end
    %----------------------------------------------
    if namefound==0
        error('wrong property name')
    elseif valuefound==0
        error('wrong property value')
    end
end
%--------------------------------------------------------------------------
%    k=2*pi/lambda;
if parray(1)==3
    t=str2double(freepv{1});
    U1=paste(zeros(t*size(U1)),U1);
end
if parray(2)==3
    t=str2double(freepv{2});
    temp=U1;
    U1=zeros(t*size(U1));
    U1(1:t:end,1:t:end)=temp;
    clear temp;
end
%---------------------- implement fourier transform ----------------------
if parray(4)~=3
    [F,dfxy(1),dfxy(2)]=fourier(U1,dxy1(1),dxy1(2));
else
    eval(['[F,dfxy] = FAFS(U1,dxy1,',freepv{4},');']);
end
clear U1
if parray(3)==3
    t=str2double(freepv{3});
    F=paste(zeros(t*size(F)),F);
end
%---------- construct the transfer function in frequency domain ----------
[M,N]=size(F);
H=zeros(M,N);
for m=1:M
    for n=1:N
        fx=(n-N/2-1)*dfxy(1);
        fy=-(m-M/2-1)*dfxy(2);
        H(m,n)=exp(1i*2*pi*z*sqrt((1/lambda)^2-fx^2-fy^2));
    end
end
%-------------------------------------------------------------------------
F=F.*H;
clear H;
%------------------ implement inverse fourier transform ------------------
if parray(5)~=3 && nargout~=0
    [U2,dxy2(1),dxy2(2)]=invfourier(F,dfxy(1),dfxy(2));
elseif parray(5)==3 && nargout~=0
    eval(['[U2,dxy2] = IFASS(F,dfxy,',freepv{5},');']);
elseif parray(5)~=3 && nargout==0
    invfourier(F,dfxy(1),dfxy(2));
else
    eval(['IFASS(F,dfxy,',freepv{5},');']);
end
%--------------------------------------------------------------------------
switch nargout
    case 1
        varargout{1}=U2;
    case 2
        varargout{1}=U2;
        varargout{2}=dxy2;
end
回复此楼

» 本帖附件资源列表

  • 欢迎监督和反馈:小木虫仅提供交流平台,不对该内容负责。
    本内容由用户自主发布,如果其内容涉及到知识产权问题,其责任在于用户本人,如对版权有异议,请联系邮箱:xiaomuchong@tal.com
  • 附件 1 : ASP.m
  • 2012-07-12 20:21:26, 5.26 K

» 猜你喜欢

光学工程
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 efish424 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 听说今天filecode变了 +16 布布和一二 2026-08-06 30/1500 2026-08-06 21:37 by 虫友是什么虫
[基金申请] filecode +10 等待解的谜 2026-08-06 14/700 2026-08-06 21:16 by zhanghaozhu
[基金申请] 固定端突然变了,今天 +3 archvillain 2026-08-06 7/350 2026-08-06 21:05 by archvillain
[基金申请] filecode +8 布布和一二 2026-08-06 11/550 2026-08-06 20:41 by tangpu318
[基金申请] 大家散了吧,后缀研究没有意义,别浪费时间了,过好目前的每一天,不要焦虑 +5 Tide man 2026-08-06 6/300 2026-08-06 20:19 by 苏知砚
[基金申请] 基金中了 +4 laoda193707 2026-08-06 4/200 2026-08-06 18:56 by olivermiaoer
[有机交流] 一个有机合成实验室都需要哪些设备? 50+3 kf2781974 2026-07-31 12/600 2026-08-06 15:11 by eddyin
[基金申请] 求各位大神看下 100+6 hpkpkpkp 2026-08-05 33/1650 2026-08-06 14:49 by zhiyanjiang
[教师之家] 咨询面上基金 +4 李长云 2026-07-31 7/350 2026-08-06 11:20 by 李长云
[基金申请] 影响面上的因素 +8 布布和一二 2026-08-05 11/550 2026-08-06 10:41 by 宝贝虫子
[基金申请] 8月时间戳变的,举个手。玩一下,释放压力 +9 archvillain 2026-08-04 11/550 2026-08-05 20:06 by wlwhappy
[基金申请] 面上再次挂了,太难了,躺也躺不了,倦也卷不过,小学校之殇! +22 低垂的野花 2026-07-31 30/1500 2026-08-05 18:03 by 低垂的野花
[基金申请] 好消息?这个有何含义??? +8 Tide man 2026-08-05 10/500 2026-08-05 16:14 by xmuxiaoyu
[考博] 【2027博士申请】纳米药物递送方向 20+3 13586093586 2026-08-03 4/200 2026-08-05 09:59 by lfy8008
[基金申请] 有没有H口的?有收到消息的吗? +3 超级海虾 2026-08-04 3/150 2026-08-04 17:26 by 学教育滴
[论文投稿] 十年后又回来了,论文投稿求助 +3 哈哈114477 2026-08-01 3/150 2026-08-04 15:40 by tegsgjy20
[基金申请] 纯娱乐,不喜欢勿喷 +7 Tide man 2026-08-04 10/500 2026-08-04 15:10 by loufangrui
[基金申请] 面上提前没消息,有中的吗 +14 archvillain 2026-08-02 18/900 2026-08-04 14:42 by archvillain
[基金申请] 娱乐 +4 Tide man 2026-08-03 4/200 2026-08-04 11:51 by wgch518
[基金申请] 什么时候能放榜呀? +3 Jacob678 2026-08-03 3/150 2026-08-03 16:14 by gltch
信息提示
请填处理意见