view general/arrutils/mzip.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children
line wrap: on
line source
% mzip - Apply array to multiple index arrays
% 
% mzip :: [[N,M]->D], [[L]->[N]], [[L]->[M]] -> [[L]->D].
%
% The name mzip is meant to suggest Matrix or Multiple Zip,
% with zip referring to the functional programming sort of 
% zip where you can apply a function of N arguments to N
% lists of arguments and get a list of return values.
% eg, mzip(x,[2 4 1],[3 2 2]) = [x(2,3) x(4,2) x(1,2)].

function B=mzip(A,varargin), B=A(sub2ind(size(A),varargin{:}));