I’d like to generate indices for an n-dimensional array with ndgrid. Since the dimension may change, is there a way to wrap ndgrid so that the number of outputs for ndgrid is dynamic? Say for example, I want the output for a 2 dimension array to be:
[output{1} output{2}]=ndgrid(1:5)
and the output for a 3 dimension array to be:
[output{1} output{2} output{3}]=ndgrid(1:5)
so on and so forth…
If you want different sizes for the different dimensions, you might want to consider something like:
creating adjacency matrix.
The relevant part is: