I\'m a little surprised that MATLAB doesn\'t have a Map function, so I hacked one together myself since it\'s something I can\'t live without. Is there a better version out
It seems that the built-in arrayfun doesn't work if the result needed is an array of function: eg: map(@(x)[x x^2 x^3],1:10)
slight mods below make this work better:
function results = map(f,list)
% why doesn't MATLAB have a Map function?
for k = 1:length(list)
if (k==1)
r1=f(list(k));
results = zeros(length(r1),length(list));
results(:,k)=r1;
else
results(:,k) = f(list(k));
end;
end;
end