Home > General-Functions > Statistics > distchck.m

distchck

PURPOSE ^

DISTCHCK Checks the argument list for the probability functions.

SYNOPSIS ^

function [errorcode,varargout] = distchck(nparms,varargin)

DESCRIPTION ^

DISTCHCK Checks the argument list for the probability functions.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [errorcode,varargout] = distchck(nparms,varargin)
0002 %DISTCHCK Checks the argument list for the probability functions.
0003 
0004 %   Copyright 1993-2004 The MathWorks, Inc.
0005 %   $Revision: 1.1.8.1 $  $Date: 2010/03/16 00:13:22 $
0006 
0007 errorcode = 0;
0008 varargout = varargin;
0009 
0010 if nparms == 1
0011     return;
0012 end
0013 
0014 % Get size of each input, check for scalars, copy to output
0015 isscalar = (cellfun('prodofsize',varargin) == 1);
0016 
0017 % Done if all inputs are scalars.  Otherwise fetch their common size.
0018 if (all(isscalar)), return; end
0019 
0020 n = nparms;
0021 
0022 for j=1:n
0023    sz{j} = size(varargin{j});
0024 end
0025 t = sz(~isscalar);
0026 size1 = t{1};
0027 
0028 % Scalars receive this size.  Other arrays must have the proper size.
0029 for j=1:n
0030    sizej = sz{j};
0031    if (isscalar(j))
0032       vj = varargin{j};
0033       if isnumeric(vj)
0034          t = zeros(size1,class(vj));
0035       else
0036          t = zeros(size1);
0037       end
0038       t(:) = varargin{j};
0039       varargout{j} = t;
0040    elseif (~isequal(sizej,size1))
0041       errorcode = 1;
0042       return;
0043    end
0044 end

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005