function abcd = optics2abcd( optics ) % converts optics ellements to full abcd matrix % assuming that the last position along propagation coinsides % with the last optical element optics = arrange_optics_along_x( optics ); abcd = [1,0; 0, 1]; d=0; N=length(optics); for i=1:N d=optics{i}.x - d; % distance between optical elements abcd= optics{i}.abcd * abcd_free_space(d) * abcd; end end