From b07d219465e3c2c54390f107ba19f02f6574e403 Mon Sep 17 00:00:00 2001 From: Matt Argao Date: Thu, 29 Nov 2012 17:20:02 -0500 Subject: Check if optics are already arranged --- arrange_optics_along_x.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'arrange_optics_along_x.m') diff --git a/arrange_optics_along_x.m b/arrange_optics_along_x.m index 62db960..817656a 100644 --- a/arrange_optics_along_x.m +++ b/arrange_optics_along_x.m @@ -6,9 +6,14 @@ function optics = arrange_optics_along_x(optics_unsorted) x=zeros(1,N); for i=1:N x(i)=optics_unsorted{i}.x; - end + end - [xs,indx]=sort(x); + if issorted(x) + optics = optics_unsorted; + return + end + + [xs,indx]=sort(x); cntr=1; for i=indx optics{cntr}=optics_unsorted{i}; -- cgit v1.2.3