comparison toolboxes/FullBNT-1.0.7/KPMstats/distchck.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [errorcode,out1,out2,out3,out4] = distchck(nparms,arg1,arg2,arg3,arg4)
2 %DISTCHCK Checks the argument list for the probability functions.
3
4 % B.A. Jones 1-22-93
5 % Copyright (c) 1993-98 by The MathWorks, Inc.
6 % $Revision: 1.1.1.1 $ $Date: 2005/04/26 02:29:18 $
7
8 errorcode = 0;
9
10 if nparms == 1
11 out1 = arg1;
12 return;
13 end
14
15 if nparms == 2
16 [r1 c1] = size(arg1);
17 [r2 c2] = size(arg2);
18 scalararg1 = (prod(size(arg1)) == 1);
19 scalararg2 = (prod(size(arg2)) == 1);
20 if ~scalararg1 & ~scalararg2
21 if r1 ~= r2 | c1 ~= c2
22 errorcode = 1;
23 return;
24 end
25 end
26 if scalararg1
27 out1 = arg1(ones(r2,1),ones(c2,1));
28 else
29 out1 = arg1;
30 end
31 if scalararg2
32 out2 = arg2(ones(r1,1),ones(c1,1));
33 else
34 out2 = arg2;
35 end
36 end
37
38 if nparms == 3
39 [r1 c1] = size(arg1);
40 [r2 c2] = size(arg2);
41 [r3 c3] = size(arg3);
42 scalararg1 = (prod(size(arg1)) == 1);
43 scalararg2 = (prod(size(arg2)) == 1);
44 scalararg3 = (prod(size(arg3)) == 1);
45
46 if ~scalararg1 & ~scalararg2
47 if r1 ~= r2 | c1 ~= c2
48 errorcode = 1;
49 return;
50 end
51 end
52
53 if ~scalararg1 & ~scalararg3
54 if r1 ~= r3 | c1 ~= c3
55 errorcode = 1;
56 return;
57 end
58 end
59
60 if ~scalararg3 & ~scalararg2
61 if r3 ~= r2 | c3 ~= c2
62 errorcode = 1;
63 return;
64 end
65 end
66
67 if ~scalararg1
68 out1 = arg1;
69 end
70 if ~scalararg2
71 out2 = arg2;
72 end
73 if ~scalararg3
74 out3 = arg3;
75 end
76 rows = max([r1 r2 r3]);
77 columns = max([c1 c2 c3]);
78
79 if scalararg1
80 out1 = arg1(ones(rows,1),ones(columns,1));
81 end
82 if scalararg2
83 out2 = arg2(ones(rows,1),ones(columns,1));
84 end
85 if scalararg3
86 out3 = arg3(ones(rows,1),ones(columns,1));
87 end
88 out4 =[];
89
90 end
91
92 if nparms == 4
93 [r1 c1] = size(arg1);
94 [r2 c2] = size(arg2);
95 [r3 c3] = size(arg3);
96 [r4 c4] = size(arg4);
97 scalararg1 = (prod(size(arg1)) == 1);
98 scalararg2 = (prod(size(arg2)) == 1);
99 scalararg3 = (prod(size(arg3)) == 1);
100 scalararg4 = (prod(size(arg4)) == 1);
101
102 if ~scalararg1 & ~scalararg2
103 if r1 ~= r2 | c1 ~= c2
104 errorcode = 1;
105 return;
106 end
107 end
108
109 if ~scalararg1 & ~scalararg3
110 if r1 ~= r3 | c1 ~= c3
111 errorcode = 1;
112 return;
113 end
114 end
115
116 if ~scalararg1 & ~scalararg4
117 if r1 ~= r4 | c1 ~= c4
118 errorcode = 1;
119 return;
120 end
121 end
122
123 if ~scalararg3 & ~scalararg2
124 if r3 ~= r2 | c3 ~= c2
125 errorcode = 1;
126 return;
127 end
128 end
129
130 if ~scalararg4 & ~scalararg2
131 if r4 ~= r2 | c4 ~= c2
132 errorcode = 1;
133 return;
134 end
135 end
136
137 if ~scalararg3 & ~scalararg4
138 if r3 ~= r4 | c3 ~= c4
139 errorcode = 1;
140 return;
141 end
142 end
143
144
145 if ~scalararg1
146 out1 = arg1;
147 end
148 if ~scalararg2
149 out2 = arg2;
150 end
151 if ~scalararg3
152 out3 = arg3;
153 end
154 if ~scalararg4
155 out4 = arg4;
156 end
157
158 rows = max([r1 r2 r3 r4]);
159 columns = max([c1 c2 c3 c4]);
160 if scalararg1
161 out1 = arg1(ones(rows,1),ones(columns,1));
162 end
163 if scalararg2
164 out2 = arg2(ones(rows,1),ones(columns,1));
165 end
166 if scalararg3
167 out3 = arg3(ones(rows,1),ones(columns,1));
168 end
169 if scalararg4
170 out4 = arg4(ones(rows,1),ones(columns,1));
171 end
172 end
173