aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Argao <mcargao@email.wm.edu>2012-11-29 17:03:52 -0500
committerMatt Argao <mcargao@email.wm.edu>2012-11-29 17:03:52 -0500
commite3ac1a7a63f30b33e8b8e7d6817a835352a1064f (patch)
tree3ae5a95e2a9e686b3e2b7d525db5e29c45434fd4
parent91a5cf152b0f7c04d40ef5cb1634eeff330989ad (diff)
downloadmode_match-e3ac1a7a63f30b33e8b8e7d6817a835352a1064f.tar.gz
mode_match-e3ac1a7a63f30b33e8b8e7d6817a835352a1064f.zip
Move from structure to variable to speed up runtime
-rw-r--r--gbeam_propagation_froward_only.m9
1 files changed, 5 insertions, 4 deletions
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