Mercurial > hg > ishara
view general/cellutils/cellzip.m @ 58:ba866ae124c6
Now accepts single color index for all points.
author | samer |
---|---|
date | Fri, 09 Oct 2015 13:01:37 +0100 |
parents | 47cb292350f3 |
children |
line wrap: on
line source
function Y=cellzip(fn,varargin) % cellzip - Zip cell arrays with a function % % cellzip :: ( % (D1,...,Dn)->R ~ function of n arguments, % {[size]->D1}, ..., {[size]->Dn} ~ n cell arrays of appropriate types % ) -> {[size]->R} ~ cell array of results % preallocate to fix size sizes=cellmap(@size,varargin); sz=sizes{1}; for i=1:nargin-1 if ~all(sizes{i}==sz), error('Sizes do not match'); end end Y=cell(sz); for i=1:prod(sz) args=cellmap(@(c)c{i},varargin); Y{i}=fn(args{:}); end