Skip to content
Snippets Groups Projects
Commit 1de42f53 authored by Charlotte Bond's avatar Charlotte Bond
Browse files

adding function which uses the FT_LG_clipping_loss analytic function for...

adding function which uses the FT_LG_clipping_loss analytic function for clipping of an LG mode to find the radius of a circular aperture which causes a given amount of clipping
parent ac1cb7a2
No related branches found
No related tags found
No related merge requests found
%
%--------------------------------------------------------------------------
% function [R_out,cl_out] = FT_find_radius_for_clipping_loss(cl_in,p,l,w,R_in)
%
% A function for Matlab which attempts to find the required radius of a
% mirror to give a specified clipping loss for a particular LG beam. The
% function uses a fitting function, fminsearch, to try and minimise the
% difference between the actual and required clipping.
%
% cl_in: required clipping loss
% p,l: indices of the LG beam
% w: beam radius at the mirror
% R_in: initial guess for the radius of the mirror. Care
% should be taken when choosing this. If the
% resulting clipping doesn't match the requirements
% well repeat the function using the outputted
% radius, R_out.
%
% R_out: radius required for given clipping, output of the
% fitting routine.
% cl_out: clipping loss given by R_out.
%
% Charlotte Bond 18.12.2010
%--------------------------------------------------------------------------
function [R_out,cl_out] = FT_radius_for_clipping_loss(cl_in,p,l,w,R_in)
params=[R_in];
% set options for fminsearch ('help optimset' gives the list of options)
options=optimset('Display','off', 'TolX', 1e-08, 'TolFun',1e-10, 'MaxIter', 10000);
% create link to test function below
f=@testfunc;
% run the fitting algorithm
params=fminsearch(f,params,options,cl_in,p,l,w);
% assign new radius of mirror
R_out=params(1);
cl_out=FT_LG_clipping_loss(p,l,w,R_out);
end
% test function for fminsearch
function [y]=testfunc(params,cl_in,p,l,w)
R=params(1);
% Use clipping loss function
cl=FT_LG_clipping_loss(p,l,w,R);
y=abs(cl-cl_in);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment