summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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