How can I apply a function to every row/column of a matrix in MATLAB?
Many built-in operations like sum and prod are already able to operate across rows or columns, so you may be able to refactor the function you are applying to take advantage of this. If that’s not a viable option, one way to do it is to collect the rows or columns into cells using mat2cell … Read more