Skip to content

Instantly share code, notes, and snippets.

@ibogun
Last active August 29, 2015 14:00
Show Gist options
  • Save ibogun/11098273 to your computer and use it in GitHub Desktop.
Save ibogun/11098273 to your computer and use it in GitHub Desktop.
Matlab tricks;
% let g be anonymous function
% apply function on every row of a matrix
applyOnEveryRaw =@(A,fun) cell2mat(cellfun(fun, num2cell(A, 2), 'UniformOutput', false));
% apply function on every column of a matrix
applyOnEveryColumn=@(A,fun) cell2mat(cellfun(fun, num2cell(A, 1), 'UniformOutput', false));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment