summaryrefslogtreecommitdiff
path: root/CTB/s2a.m
diff options
context:
space:
mode:
authorRuben Undheim <ruben.undheim@gmail.com>2016-07-05 18:02:38 +0200
committerRuben Undheim <ruben.undheim@gmail.com>2016-07-05 18:02:38 +0200
commitef962f6008f25ab7cbd4ca21bcc72b97a1e2d76f (patch)
tree8149bee93d1a3f91d4503bfb3853adac4af0a85e /CTB/s2a.m
Imported Upstream version 0.0.34
Diffstat (limited to 'CTB/s2a.m')
-rw-r--r--CTB/s2a.m31
1 files changed, 31 insertions, 0 deletions
diff --git a/CTB/s2a.m b/CTB/s2a.m
new file mode 100644
index 0000000..4f795ef
--- /dev/null
+++ b/CTB/s2a.m
@@ -0,0 +1,31 @@
+function a = s2a(s,ref)
+% a = s2a(s [,ref])
+%
+% Scattering to ABCD transformation (only for 2x2xf matrices)
+%
+% input:
+% s: S-matrix matrix 2x2xf (f: number of frequencies)
+% ref: (optional) reference impedance (default 50 Ohm)
+%
+% output:
+% a: ABCD 2x2xf
+%
+% Reference: David M. Pozar "Microwave Engineering"
+%
+% Sebastian Held <sebastian.held@gmx.de>
+% Sep 1 2010
+
+if nargin < 2
+ Z0 = 50;
+else
+ Z0 = ref;
+end
+
+S11 = squeeze(s(1,1,:));
+S12 = squeeze(s(1,2,:));
+S21 = squeeze(s(2,1,:));
+S22 = squeeze(s(2,2,:));
+a(1,1,:) = ((1+S11).*(1-S22) + S12.*S21) ./ (2*S21);
+a(1,2,:) = Z0 .* ((1+S11).*(1+S22) - S12.*S21) ./ (2*S21);
+a(2,1,:) = 1./Z0 .* ((1-S11).*(1-S22) - S12.*S21) ./ (2*S21);
+a(2,2,:) = ((1-S11).*(1+S22) + S12.*S21) ./ (2*S21);