comparison general/numerical/packvec.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children
comparison
equal deleted inserted replaced
3:3f77126f7b5f 4:e44f49929e56
1 function X=packvec(varargin)
2 % packvec - Pack coordinate values in separate arrays into one big array
3 %
4 % packvec :: {[K]->[[E]]} -> [[K,E]].
5 %
6 % There is also a variable argument list form:
7 %
8 % packvec :: [[E]], [[E]] -> [[2,E]].
9 % packvec :: [[E]], [[E]], [[E]] -> [[3,E]].
10 % etc..
11
12
13 if nargin==1 && iscell(varargin{1})
14 Y=varargin{1};
15 else
16 Y=varargin;
17 end
18 [Y{:}]=promote(Y{:});
19 Y=cellmap(@(y)reshape(y,[1 size(y)]),Y);
20 X=cat(1,Y{:});
21
22