MatrixBerryCore
num2cell.m
Go to the documentation of this file.
1 function resCell = num2cell(inpArray,varargin)
2 import mxberry.core.throwerror;
3 if ~isempty(inpArray)
4  resCell=num2cell(inpArray,varargin{:});
5 elseif nargin==1
6  resCell=cell(size(inpArray));
7 elseif nargin==2
8  dimVec=varargin{1};
9  sizeVec=[size(inpArray),ones(1,max(dimVec)-ndims(inpArray))];
10  inpArg=num2cell(sizeVec);
11  isBreak=true(size(sizeVec));
12  isBreak(dimVec)=false;
13  inpArg(isBreak)=cellfun(@(x)ones(1,x),inpArg(isBreak),'UniformOutput',false);
14  resCell=mat2cell(inpArray,inpArg{:});
15 else
16  throwerror('wrongInput',...
17  'number of input arguments should not exceed 2');
18 end
function num2cell(in inpArray, in varargin)
NUM2CELL is an extension of Matlab built-in function "num2cell" designed to work correctly with empty...
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...