When you have a function that takes a variable amount of arguments (like ndgrid), how can you pass an arbitrary list of arguments to that function?
For example I want to make it so that sometimes I pass two vectors to ndgrid and get out two matrices, i.e.,
[X1,X2] = ndgrid(x1,x2);
But other times I might have more X's, so I'll want
[X1,X2,X3,X4] = ndgrid(x1,x2,x3,x4)
- Is there any kind of structure I can use to store a list of an unknown number of arguments and then just give that list to a function? And,
- Is there a way to retrieve all of the outputs from a function, when you don't know how many there will be?