summaryrefslogtreecommitdiff
path: root/CTB/s2a.m
blob: 4f795efe33ef19bf619952f0a52944e67ff1c8d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);