Mercurial > hg > ishara
view general/arrutils/mapcols.m @ 42:ae596261e75f
Various fixes and development to audio handling
author | samer |
---|---|
date | Tue, 02 Dec 2014 14:51:13 +0000 |
parents | fbc0540a9208 |
children |
line wrap: on
line source
function Y=mapcols(f,X) % mapcols - Map a function of a vector over the columns of an array % % mapcols :: % ([[N]->A] -> [[M]->B]) ~'function maps a column of A to one of B', % [[N,L]->A] % -> [[M,L]->B]. n=size(X,2); if n==0, Y=[]; else y1=f(X(:,1)); if size(y1,2)>1 Y=repmat(y1(:),1,n); for i=2:n Y(:,i)=flatten(f(flatten(X(:,i)))); end else Y=repmat(y1,1,n); for i=2:n, Y(:,i)=f(X(:,i)); end end end