MATLAB: How to increase the number of inputs and outputs of ndgrid

combinationcreating variablesndgrid

Dear all,
I am trying to create a matrix of all possible combinations of a set number of vectors. For instance, if I have 3 vectors (got this tip from the forum):
A = [1,2,3];B = [4,5,6];C = [7,8,9]; % For instance
[ca, cb, cc] = ndgrid(A, B, C);
combs = [ca(:), cb(:), cc(:)]
Now, if I want all combinations of 4 vectors I would use
[ca, cb, cc, dd] = ndgrid(A, B, C, D);
combs = [ca(:), cb(:), cc(:), cd(::)]
I'm wondering if there is a way of automating this by having the number of variables in the inputs and outputs to increase automatically. Tried everything so far.. Please help
Thanks!!