0001 function b = boundarymatrix(q,g,h,r,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 switch nargin
0019 case {0}
0020 q = '0';
0021 g = '0';
0022 h = [];
0023 r = [];
0024 case {1}
0025 g = q;
0026 q = '0';
0027 h = [];
0028 r = [];
0029 case {2}
0030 h = [];
0031 r = [];
0032 otherwise
0033
0034 end
0035 optargs = length(varargin);
0036 nobdrs = max(1,1+optargs/4);
0037
0038
0039 b = cell(nobdrs);
0040
0041 if ~mod(optargs,4)==0,
0042 error('argument list has wrong lenght)')
0043 end
0044
0045 if isempty(h)&&isempty(r),
0046 b1 = 1;
0047 b1(2,1) = 0;
0048 b1(3,1) = length(q);
0049 b1(4,1) = length(g);
0050 b1=[b1;double(q)';double(g)'];
0051 elseif isempty(q)&&isempty(g)
0052 b1 = 1;
0053 b1(2,1) = 1;
0054 b1(3,1) = 1;
0055 b1(4,1) = 1;
0056 b1(5,1) = length(h);
0057 b1(6,1) = length(r);
0058 b1(7,1) = 48;
0059 b1(8,1) = 48;
0060 b1 = [b1;double(h)';double(r)'];
0061 end
0062 b{1} = b1;
0063
0064
0065 l = 1;
0066
0067 for k = 2:nobdrs,
0068 q = varargin{l}; l = l+1;
0069 g = varargin{l}; l = l+1;
0070 h = varargin{l}; l = l+1;
0071 r = varargin{l}; l = l+1;
0072 if isempty(h)&&isempty(r),
0073 b1 = 1;
0074 b1(2,1) = 0;
0075 b1(3,1) = length(q);
0076 b1(4,1) = length(g);
0077 b1 = [b1;double(q)';double(g)'];
0078 b{k} = b1;
0079 elseif isempty(q)&&isempty(g)
0080 b1 = 1;
0081 b1(2,1) = 1;
0082 b1(3,1) = 1;
0083 b1(4,1) = 1;
0084 b1(5,1) = length(h);
0085 b1(6,1) = length(r);
0086 b1(7,1) = 48;
0087 b1(8,1) = 48;
0088 b1 = [b1;double(h)';double(r)'];
0089 b{k} = b1;
0090 end
0091 end
0092
0093
0094
0095
0096
0097 if nobdrs==1,
0098 bb=[b{1},b{1}];
0099 else
0100 maxlengthb = 0;
0101 for l = 1:k,
0102 if length(b{l})>maxlengthb,
0103 maxlengthb = length(b{l});
0104 end
0105 end
0106 bb = zeros(maxlengthb,nobdrs);
0107 for l = 1:k,
0108 bb(1:length(b{l}),l)=b{l};
0109 end
0110 end
0111 b=bb;
0112 end