aboutsummaryrefslogtreecommitdiff
path: root/abcd2self_repeating_q.m
diff options
context:
space:
mode:
Diffstat (limited to 'abcd2self_repeating_q.m')
-rw-r--r--abcd2self_repeating_q.m19
1 files changed, 19 insertions, 0 deletions
diff --git a/abcd2self_repeating_q.m b/abcd2self_repeating_q.m
new file mode 100644
index 0000000..cd60aaf
--- /dev/null
+++ b/abcd2self_repeating_q.m
@@ -0,0 +1,19 @@
+function [q] = abcd2self_repeating_q( abcd_cavity )
+% this find q such that q = (A*q+B)/(C*q+D)
+% i.e q after abcd is exactly the same
+% very handy for cavity mode calculations
+
+% spelling out abcd coefficients
+[A, B, C, D] = abcd2ABCD( abcd_cavity );
+
+if ~isCavityStable(abcd_cavity)
+ display('ABCD is unstable !');
+ display('We should stop now. There is no stable self-repeating mode with such ABCD');
+ error('Not possible to calculate a self-repeating mode with the unstable ABCD');
+end
+
+% q is the solution of quadratic equation, we chose one with positive waist size
+q = ( -(D-A) - sqrt( (D-A)^2 + 4*C*B ) ) / (2*C);
+
+end
+