I have a matrix A of arbitrary dimensions m x n and wish to fill it using an equation, for example, for every element a_ij of A<
A
m
n
A<
An alternative using ndgrid:
ndgrid
[I, J] = ndgrid(1:m, 1:n); A = I.^2 + J.^2;