% templateh02_3.m % % template for fresnel calculations % % search through script and replace all ?? with appropriate command % also requires fwhm script % i = sqrt(-1); samplesize = 0.5; % sample size for plots and convolution mm plotext = 30; % extent of plots in mm a = 5; % aperture dimension in mm x = [-(plotext):samplesize:(plotext)]; % x axis for plots convx = [-(plotext+a):samplesize:(plotext+a)]; % padded for convolution x0 = [-a:samplesize:a]; % x axis for aperture % aperture function for convolution % to help with plotting... ln = length(x); lap = length(x0); zlist = [25 50 100 200]; % depth planes in mm for cs = 1:2 str = sprintf('fresnel approximation, case %d ',cs ); disp(str); % % insert the aperture function here % if cs == 1 % this is the plain aperture ap = ones(size(x0)); else % you make a focusing system, depth = 50 ap = ?? end for lp = 1:4 subplot(2,2,lp); z = zlist(lp); % % caclulate the fresnel blurring kernal % use convx as an input % qph = ?? % perform convolution resp = conv(qph,ap); % normalize resp = abs(resp) / max(abs(resp)); % % plot response % str = sprintf('z=%d, fwhw = %f',z,fwhm(abs(resp(lap:lap+ln-1)))*samplesize); disp(str); plot(x, abs(resp(lap:lap+ln-1))); xlabel('displacement [mm]'); ylabel('response magnitude'); title(sprintf('z = %g mm', z)) end disp 'hit key'; pause end disp 'far field approximation' % now do far-field/focal plane approximation for lp = 1:4 subplot(2,2,lp); z = zlist(lp); % % calc normalized response (using x as input) % resp = ?? % % plot response % str = sprintf('z=%d, fwhw = %f',z,fwhm(abs(resp))*samplesize); disp(str); plot(x, abs(resp)); xlabel('displacement [mm]'); ylabel('response magnitude'); title(sprintf('z = %g mm', z)) end