MatrixBerryCore
isvalidsize.m
Go to the documentation of this file.
1 function isValidVec=isvalidsize(varargin)
2 sizeCell=cellfun(@size,varargin(1:end-1),'UniformOutput',false);
3 sizeVec=varargin{end};
4 nCheckDim=numel(sizeVec);
5 %
6 if nCheckDim==0
7  isValidVec=max(cellfun(@prod,sizeCell))==0;
8 else
9  if nCheckDim==1
10  sizeVec=[sizeVec 1];
11  nCheckDim=2;
12  end
13  %
14  nDimVec=cellfun('ndims',varargin(1:end-1));
15  maxDim=max([nDimVec nCheckDim]);
16  addVec=maxDim-nDimVec;
17  isnZero=addVec~=0;
18  if any(isnZero)
19  addVec(~isnZero)=[];
20  addCell=num2cell(addVec);
21  sizeCell(isnZero)=cellfun(@(x,y)[x ones(1,y)],...
22  sizeCell(isnZero),addCell,...
23  'UniformOutput',false);
24  end
25  isToCheck=~isnan(sizeVec);
26  checkSize=sizeVec(isToCheck);
27  %
28  isValidVec=(cellfun(@(x) isequal(x(isToCheck),checkSize),sizeCell))&...
29  (nDimVec<=nCheckDim);
30 end
function num2cell(in inpArray, in varargin)
NUM2CELL is an extension of Matlab built-in function "num2cell" designed to work correctly with empty...
function isvalidsize(in varargin)
ISVALIDSIZE compares size of input arrays with size mask. Size mask can contain nans that allow any s...