#### /verify_vsf_lookup_table.m

Objective C | 40 lines | 27 code | 13 blank | 0 comment | 4 complexity | 9f8d4aeebe7ff485164ed9b2502f5b6b MD5 | raw file

1% Test the method for calculating scattering lengths and choosing values 2% from the VSF (volume scattering function) distribution 3 4num_photons = 1e6; 5inv_b = 1; 6 7[cdf_scatter,angle] = generate_scatter('measured','petzold_avg'); 8 9rand_array = rand(num_photons,3); % generate a matrix for each photon with rand propogation, roll, and pitch 10rand_array(:,3) = rand_array(:,3).*2.*pi; %% Uniformly distributed over 0 -2Pi 11 12 13 14 15r = zeros(1,num_photons); 16theta = zeros(1,num_photons); 17 18% iterate over every single photon to calculate new position and 19% whether it was received or not. 20for i = 1:num_photons 21 22 r(i) = -inv_b*log(rand_array(i,1)); % randomly generate optical path length 23 24 %Generate scattering angle from beam spread function 25 k = 1; 26 while rand_array(i,2) > cdf_scatter(k) 27 k = k+1; 28 end 29 theta(i) = angle(k); 30 31end 32 33hold on; 34 35figure(3);[N,X] = hist(r,100); 36plot(X,N./N(1)); 37figure(4);[N,X] = hist(theta,500); 38plot(X,N./N(1)); 39figure(5);[N,X] = hist(rand_array(:,3),360); 40plot(X,N./N(1));