opt_grid.m
来自「Matlab实现光线跟踪算法」· M 代码 · 共 64 行
M
64 行
function [opt1] = opt_grid(opt_type,opt_args)% OPT_GRID - Simple difractive grating% OPT_TYPE should be 'grid' (hm good and vital argument), OPT_SPEC% should be a string matrix, see README_OPT for specification.% Necessary specification fields: % r1, dxdydx, linespmm,% glass should be name of the glass type, the other 1x3 array% Optional specification fields:% normal, e_slit,% example OPT_SPEC:% 'r1 12 0 0'% 'dxdydz 0 2 1'% 'linespmm 600'% 'normal cos(10*pi/180) sin(10*pi/180) 0'% % Calling:% [opt1] = opt_grid(opt_type,opt_args)% % See also OPT_APERTURE, OPT_SCREEN, OPT_LENS, OPT_PRISM, OPT_SLIT% Version: 1.0% Copyright: Bjorn Gustavsson 20020430if nargin ~= 2, help opt_grid; ok = 0; return;end;opt1 = opt_elem(opt_type);opt1.glass = 'air'; % % defaultsopt1.r(2:3) = 0; % Grid centered on the optical axisopt1.n = [1 0 0]; % Grid paralell with the optical axisopt1.e_slits = [0 0 1]; % Grid slits paralell with e_z% set the necessary ones:% grid sizeii = opt_findstr(opt_args,'dydz');opt1.dxdydz = str2num(opt_args(ii,12:end));% grid positionii = opt_findstr(opt_args,'r1');opt1.r = str2num(opt_args(ii,12:end));% lines per mmii = opt_findstr(opt_args,'linespmm');opt1.lpmm = str2num(opt_args(ii,12:end));% set the optional onesii = opt_findstr(opt_args,'normal');if length(ii) == 1 opt1.n = str2num(opt_args(ii(1),12:end)); endii = opt_findstr(opt_args,'e_slit');if length(ii) == 1 opt1.e_slits = str2num(opt_args(ii(1),12:end)); end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?