Good thought, Ethan!  In fact, if you do it that way, broadcasting should
work--just divide by S.  (I'm not at a computer, so please test.)

Cheers,
   Kevin

On Wednesday, August 27, 2014, Ethan Anderes <[email protected]> wrote:

> You could also re-arrange the indices and move the for loop to the last
> index
>
> function f(n)
>     A = rand(n, n, 3)
>     S = rand(n, n)
>     for k = 1:size(A, 3)
>         A[:,:,k] = A[:,:,k] ./ S
>     end
>     return A
> end
>
> This works since A[:,:,k] is a 2-d array but A[k,:,:] is a 3-d array.
> ​
>

Reply via email to