From 3dc6cbebbd58bc554e567da44bd98cf4b8c5fe14 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Sun, 19 Aug 2012 00:12:50 +0200 Subject: [PATCH] modified to work with octave-3.2.4 --- .../examples/microstrip/directional_coupler.m | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/matlab/examples/microstrip/directional_coupler.m b/matlab/examples/microstrip/directional_coupler.m index fdcc615..8ba86f2 100644 --- a/matlab/examples/microstrip/directional_coupler.m +++ b/matlab/examples/microstrip/directional_coupler.m @@ -13,7 +13,7 @@ function directional_coupler % % Tested with % - Matlab 2010b -% - Octave 3.3.54 +% - Octave 3.2.4 % - openEMS v0.0.17 % % (C) 2010 Sebastian Held @@ -157,9 +157,9 @@ FDTD = SetBoundaryCond( FDTD, BC ); %% Write openEMS compatible xml-file if runSimulation - [~,~,~] = rmdir(Sim_Path,'s'); + [dummy,dummy,dummy] = rmdir(Sim_Path,'s'); end -[~,~,~] = mkdir(Sim_Path); +[dummy,dummy,dummy] = mkdir(Sim_Path); WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); if showStructure @@ -233,3 +233,29 @@ else axis equal axis off end + + +function s = y2s(y, ZL) +% S = y2s(Y, ZL) +% +% Admittance to Scattering transformation +% for square matrices at multiple frequencies +% +% ZL defaults to 50 Ohm + +if nargin < 2 + ZL = 50; +end + +if size(size(y),2) > 2 + nF = size(y,3); +else + nF = 1; +end + +I = diag(ones(1, size(y,2)))/ZL; + +for i=1:nF + %s(:,:,i) = inv(I+y(:,:,i)) * (I-y(:,:,i)); + s(:,:,i) = (I+y(:,:,i)) \ (I-y(:,:,i)); +end