-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdistchck.m
44 lines (36 loc) · 983 Bytes
/
distchck.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function [errorcode,varargout] = distchck(nparms,varargin)
%DISTCHCK Checks the argument list for the probability functions.
% Copyright 1993-2004 The MathWorks, Inc.
% $Revision: 2.12.4.2 $ $Date: 2004/01/24 09:33:22 $
errorcode = 0;
varargout = varargin;
if nparms == 1
return;
end
% Get size of each input, check for scalars, copy to output
isscalar = (cellfun('prodofsize',varargin) == 1);
% Done if all inputs are scalars. Otherwise fetch their common size.
if (all(isscalar)), return; end
n = nparms;
for j=1:n
sz{j} = size(varargin{j});
end
t = sz(~isscalar);
size1 = t{1};
% Scalars receive this size. Other arrays must have the proper size.
for j=1:n
sizej = sz{j};
if (isscalar(j))
vj = varargin{j};
if isnumeric(vj)
t = zeros(size1,class(vj));
else
t = zeros(size1);
end
t(:) = varargin{j};
varargout{j} = t;
elseif (~isequal(sizej,size1))
errorcode = 1;
return;
end
end