From e3ac1a7a63f30b33e8b8e7d6817a835352a1064f Mon Sep 17 00:00:00 2001 From: Matt Argao Date: Thu, 29 Nov 2012 17:03:52 -0500 Subject: Move from structure to variable to speed up runtime --- gbeam_propagation_froward_only.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gbeam_propagation_froward_only.m') diff --git a/gbeam_propagation_froward_only.m b/gbeam_propagation_froward_only.m index 93fe2c7..afc1316 100644 --- a/gbeam_propagation_froward_only.m +++ b/gbeam_propagation_froward_only.m @@ -22,9 +22,10 @@ function q = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements) for k = 1:length(optics_elements) el=optics_elements{k}; - if el.x > x_last_calc + elx = el.x; + if elx > x_last_calc %Find all points to the left of the current optical element - index = (x_last_calc <= x_pos) & (x_pos < el.x); + index = (x_last_calc <= x_pos) & (x_pos < elx); if any(index) x=x_pos(index); q_tmp=q_after_free_space(q_last_calc,x-x_last_calc); @@ -33,10 +34,10 @@ function q = gbeam_propagation_froward_only(x_pos, q_in, x_in, optics_elements) q_last_calc=q_tmp(end); end %propagate beam up to the lens - q_at_lens = q_after_free_space(q_last_calc,el.x - x_last_calc); + q_at_lens = q_after_free_space(q_last_calc,elx - x_last_calc); %Applying lens transformation q_last_calc=q_after_abcd(q_at_lens,el.abcd); - x_last_calc = el.x; + x_last_calc = elx; end end -- cgit v1.2.3