diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-04-12 17:29:09 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-04-12 17:29:09 -0400 |
commit | 6f758b106dc359fa18b5f332edc0b4f18fbdd6ba (patch) | |
tree | c6d4aa57ab9c185804c3d867340e675129a25986 | |
parent | 6cd92eb7bd2bc23d708e872a8fee1900ee15eef6 (diff) | |
download | mode_match-6f758b106dc359fa18b5f332edc0b4f18fbdd6ba.tar.gz mode_match-6f758b106dc359fa18b5f332edc0b4f18fbdd6ba.zip |
added comments and variables name are more readable now
Ignore-this: 41c15ffd065ac70f4508aa9a3f4803ce
darcs-hash:20110412212909-067c0-a9a6d4ffa182651939b7aeae5405fbd2600c567a
-rw-r--r-- | abcd.m | 45 |
1 files changed, 27 insertions, 18 deletions
@@ -10,27 +10,36 @@ function qnew=q_afteer_element(q_old,abcd) qnew=(q_old*abcd(1,1)+abcd(1,2))/(q_old*abcd(2,1)+abcd(2,2)); endfunction -function q = prop(x_final, q_in, elements) - q(size(x_final,2))=0; - for i=1:size(x_final,2) - x_final_i=x_final(i); - xend=0; - q_end=q_in; - for k=1:size(elements,2) - el=nth(elements,k); - if ( el.x <= x_final_i) - abcd=abcd_free_space(el.x-xend); - q_end=q_afteer_element(q_end,abcd); - q_end=q_afteer_element(q_end,el.abcd); - xend=el.x; +function q = prop(x_pos, q_in, elements) +% calculate the 'q' parameter of the Gaussian beam propagating through optical +% 'elements' array along 'x' axis at points 'x_pos' +% takes the gaussian beam with initial q_in parameter at x_pos(1) + + Np=length(x_pos); % number of 'x' points + Nel=length(elements); + q=0*x_pos; % q vector initialization + q(1)=q_in; + q_last_calc=q_in; + x_last_calc=x_pos(1); % the furthest calculated point + for i=2:Np + x_pos_i=x_pos(i); + for k=1:length(elements) + % iterates through optical elements to make sure + % we take them in account for the beam propagation + el=elements{k}; + if ( (x_last_calc < el.x) && (el.x <= x_pos_i) ) + abcd=abcd_free_space(el.x-x_last_calc); + q_last_calc=q_afteer_element(q_last_calc,abcd); + q_last_calc=q_afteer_element(q_last_calc,el.abcd); + x_last_calc=el.x; endif endfor - if (x_final_i > xend); - abcd=abcd_free_space(x_final_i-xend); - q_end=q_afteer_element(q_end,abcd); - xend=x_final_i; + if (x_pos_i > x_last_calc); + abcd=abcd_free_space(x_pos_i-x_last_calc); + q_last_calc=q_afteer_element(q_last_calc,abcd); + x_last_calc=x_pos_i; endif - q(i)=q_end; + q(i)=q_last_calc; endfor endfunction |