I am trying to see if there are other ways of coding this code sample more efficiently. Here, y is an 1xM matrix, (say, 1×1000), and z is an NxM matrix, (say, 5×1000).
mean(ones(N,1)*y.^3 .* z,2)
This code works fine, but I worry of N increases a lot, that the:
might get too wasteful and make everything slow down.