diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolboxes/FullBNT-1.0.7/KPMstats/distchck.m	Tue Feb 10 15:05:51 2015 +0000
@@ -0,0 +1,173 @@
+function [errorcode,out1,out2,out3,out4] = distchck(nparms,arg1,arg2,arg3,arg4)
+%DISTCHCK Checks the argument list for the probability functions.
+
+%   B.A. Jones  1-22-93
+%   Copyright (c) 1993-98 by The MathWorks, Inc.
+%   $Revision: 1.1.1.1 $  $Date: 2005/04/26 02:29:18 $
+
+errorcode = 0;
+
+if nparms == 1
+    out1 = arg1;
+    return;
+end
+    
+if nparms == 2
+    [r1 c1] = size(arg1);
+    [r2 c2] = size(arg2);
+    scalararg1 = (prod(size(arg1)) == 1);
+    scalararg2 = (prod(size(arg2)) == 1);
+    if ~scalararg1 & ~scalararg2
+        if r1 ~= r2 | c1 ~= c2
+            errorcode = 1;
+            return;         
+        end     
+    end
+    if scalararg1
+        out1 = arg1(ones(r2,1),ones(c2,1));
+    else
+        out1 = arg1;
+    end
+    if scalararg2
+        out2 = arg2(ones(r1,1),ones(c1,1));
+    else
+        out2 = arg2;
+    end
+end
+    
+if nparms == 3
+    [r1 c1] = size(arg1);
+    [r2 c2] = size(arg2);
+    [r3 c3] = size(arg3);
+    scalararg1 = (prod(size(arg1)) == 1);
+    scalararg2 = (prod(size(arg2)) == 1);
+    scalararg3 = (prod(size(arg3)) == 1);
+
+    if ~scalararg1 & ~scalararg2
+        if r1 ~= r2 | c1 ~= c2
+            errorcode = 1;
+            return;         
+        end
+    end
+
+    if ~scalararg1 & ~scalararg3
+        if r1 ~= r3 | c1 ~= c3
+            errorcode = 1;
+            return;                 
+        end
+    end
+
+    if ~scalararg3 & ~scalararg2
+        if r3 ~= r2 | c3 ~= c2
+            errorcode = 1;
+            return;         
+        end
+    end
+
+    if ~scalararg1
+      out1 = arg1;
+    end
+    if ~scalararg2
+      out2 = arg2;
+    end
+    if ~scalararg3
+      out3 = arg3;
+    end
+    rows = max([r1 r2 r3]);
+   columns = max([c1 c2 c3]);  
+       
+    if scalararg1
+        out1 = arg1(ones(rows,1),ones(columns,1));
+    end
+   if scalararg2
+        out2 = arg2(ones(rows,1),ones(columns,1));
+   end
+   if scalararg3
+       out3 = arg3(ones(rows,1),ones(columns,1));
+   end
+     out4 =[];
+    
+end
+
+if nparms == 4
+    [r1 c1] = size(arg1);
+    [r2 c2] = size(arg2);
+    [r3 c3] = size(arg3);
+    [r4 c4] = size(arg4);
+    scalararg1 = (prod(size(arg1)) == 1);
+    scalararg2 = (prod(size(arg2)) == 1);
+    scalararg3 = (prod(size(arg3)) == 1);
+    scalararg4 = (prod(size(arg4)) == 1);
+
+    if ~scalararg1 & ~scalararg2
+        if r1 ~= r2 | c1 ~= c2
+            errorcode = 1;
+            return;         
+        end
+    end
+
+    if ~scalararg1 & ~scalararg3
+        if r1 ~= r3 | c1 ~= c3
+            errorcode = 1;
+            return;                 
+        end
+    end
+
+    if ~scalararg1 & ~scalararg4
+        if r1 ~= r4 | c1 ~= c4
+            errorcode = 1;
+            return;                 
+        end
+    end
+
+    if ~scalararg3 & ~scalararg2
+        if r3 ~= r2 | c3 ~= c2
+            errorcode = 1;
+            return;         
+        end
+    end
+
+    if ~scalararg4 & ~scalararg2
+        if r4 ~= r2 | c4 ~= c2
+            errorcode = 1;
+            return;         
+        end
+    end
+
+    if ~scalararg3 & ~scalararg4
+        if r3 ~= r4 | c3 ~= c4
+            errorcode = 1;
+            return;         
+        end
+    end
+
+
+    if ~scalararg1
+       out1 = arg1;
+    end
+    if ~scalararg2
+       out2 = arg2;
+    end
+    if ~scalararg3
+      out3 = arg3;
+    end
+    if ~scalararg4
+      out4 = arg4;
+    end
+ 
+   rows = max([r1 r2 r3 r4]);
+   columns = max([c1 c2 c3 c4]);     
+    if scalararg1
+       out1 = arg1(ones(rows,1),ones(columns,1));
+   end
+   if scalararg2
+       out2 = arg2(ones(rows,1),ones(columns,1));
+   end
+   if scalararg3
+       out3 = arg3(ones(rows,1),ones(columns,1));
+   end
+   if scalararg4
+       out4 = arg4(ones(rows,1),ones(columns,1));
+   end
+end
+