function ret=isCavityStable (abcd_cavity) % finds if a cavity is stable baced on its abcd matrix % see eq.4 for stability condition % doi:10.1088/1464-4258/7/1/002 % http://dx.doi.org/10.1088/1464-4258/7/1/002 A=abcd_cavity(1,1); B=abcd_cavity(1,2); C=abcd_cavity(2,1); D=abcd_cavity(2,2); u= (A+D+2)/4; if ( (0 < u) && (u < 1) ) ret = true; else ret = false; end end