annotate general/cellutils/cellfilt.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents e44f49929e56
children
rev   line source
samer@4 1 function Y=cellfilt(fn,X)
samer@4 2 % cellfilt - Filter cell array with boolean test
samer@4 3 %
samer@4 4 % cellfilt :: (A->bool), {[N]->A} -> {[M]->A}.
samer@4 5 % cellfilt :: (A->bool), {[1,N]->A} -> {[1,M]->A}.
samer@4 6 %
samer@4 7 % eg, cellfilt(@iseven,{1,2,3,4}) = {2,4}
samer@4 8
samer@4 9 % SA 2008-06-27 - Now returns cell array with same orientation as input
samer@4 10
samer@4 11 Y={};
samer@4 12 [X,E]=shiftdim(X);
samer@4 13 for i=1:numel(X)
samer@4 14 if fn(X{i}), Y=vertcat(Y,X(i)); end
samer@4 15 end
samer@4 16 Y=shiftdim(Y,E);