0001 function [errorcode,varargout] = distchck(nparms,varargin)
0002
0003
0004
0005
0006
0007 errorcode = 0;
0008 varargout = varargin;
0009
0010 if nparms == 1
0011 return;
0012 end
0013
0014
0015 isscalar = (cellfun('prodofsize',varargin) == 1);
0016
0017
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
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