From f2a3b19d6e0d3c9d4b5ac6de2c8060505f6190a2 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Fri, 30 Jul 2010 17:03:34 +0200 Subject: [PATCH] matlab: allow strings as BC definition --- matlab/SetBoundaryCond.m | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/matlab/SetBoundaryCond.m b/matlab/SetBoundaryCond.m index 1d69ca0..86a00d1 100644 --- a/matlab/SetBoundaryCond.m +++ b/matlab/SetBoundaryCond.m @@ -8,9 +8,26 @@ function FDTD = SetBoundaryCond(FDTD,BC) % ----------------------- % author: Thorsten Liebig -FDTD.BoundaryCond.ATTRIBUTE.xmin=BC(1); -FDTD.BoundaryCond.ATTRIBUTE.xmax=BC(2); -FDTD.BoundaryCond.ATTRIBUTE.ymin=BC(3); -FDTD.BoundaryCond.ATTRIBUTE.ymax=BC(4); -FDTD.BoundaryCond.ATTRIBUTE.zmin=BC(5); -FDTD.BoundaryCond.ATTRIBUTE.zmax=BC(6); +if (numel(BC)~=6) + error('openEMS:SetBoundaryCond','wrong number of boundary conditions'); +end + +if isnumeric(BC) + FDTD.BoundaryCond.ATTRIBUTE.xmin=BC(1); + FDTD.BoundaryCond.ATTRIBUTE.xmax=BC(2); + FDTD.BoundaryCond.ATTRIBUTE.ymin=BC(3); + FDTD.BoundaryCond.ATTRIBUTE.ymax=BC(4); + FDTD.BoundaryCond.ATTRIBUTE.zmin=BC(5); + FDTD.BoundaryCond.ATTRIBUTE.zmax=BC(6); +elseif iscell(BC) + FDTD.BoundaryCond.ATTRIBUTE.xmin=BC{1}; + FDTD.BoundaryCond.ATTRIBUTE.xmax=BC{2}; + FDTD.BoundaryCond.ATTRIBUTE.ymin=BC{3}; + FDTD.BoundaryCond.ATTRIBUTE.ymax=BC{4}; + FDTD.BoundaryCond.ATTRIBUTE.zmin=BC{5}; + FDTD.BoundaryCond.ATTRIBUTE.zmax=BC{6}; +else + error('openEMS:SetBoundaryCond','unknown boundary condition type'); +end + + \ No newline at end of file