File: InitNetwork.m

package info (click to toggle)
openems 0.0.35%2Bdfsg.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,288 kB
  • sloc: cpp: 40,259; yacc: 580; lex: 350; makefile: 258; sh: 169; ruby: 19
file content (53 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function net = InitNetwork(freq, s_para, varargin)
% function net = InitNetwork(freq, s_para, varargin)
%
%   Init a new network with a given frequncy vector and scattering parameter set
%
% arguments:
%   freq:   frequncy vector
%   s_para: scattering parameter
%
% example:
%   % read some touchstone s-parameter file
%   [type,freq,data,ref]=read_touchstone('test.s3p');
%
%   % init network
%   net = InitNetwork(freq, data);
%   % attach a series capacity to port 2
%   net = AddElement2Port(net, 2, 'C_se', 1e-12);
%   % terminate all ports with 50 Ohms
%   net = AddElement2Port(net, 1:3, 'R_se', 50);
%   % apply 1mW to port 1 and get port currents
%   I_tot = ApplyRFPower2Port(net, 1, 1e-3);
%
% See also AddElement2Port, ApplyCurrent2Port, ApplyRFPower2Port,
%          read_touchstone, write_touchstone
%
% ------
% Cuicuit Toolbox (https://github.com/thliebig/CTB)
% (c) Thorsten Liebig, 2013

net.Z0 = 50;
net.numFreq = numel(freq);
net.numPorts = size(s_para, 1);
net.f = freq;
net.s = s_para;
net.orig.s = s_para;
net.z = s2z(net.s, net.Z0);
net.y = s2y(net.s, net.Z0);

ABCD(1,1,1:net.numFreq) = 1;
ABCD(2,2,:) = 1;

% networks attached to each port
for n=1:net.numPorts
    net.ABCD{n} = ABCD;
end

if (size(s_para, 1) ~= size(s_para, 2))
    error 'n unequal m'
end

if (size(s_para, 3) ~= net.numFreq)
    error 'number of frequencies do not match'
end