MATLAB: Create a vector without for

vector

The vector structure is like [a b c d e f g h i j]
a=1:10
b=1:10
j=1:5
vect=[]
I can use for a =1:10
for b=1:10
vect = [vect;a.b…j]
end
end
but it looks not elegant. Is there a better way to generate it?

Best Answer

a=1:10;
b=1:10;
c=1:3;
d=1:5;
[A, B, C, D] = ndgrid(uint8(a), uint8(b), uint8(c), uint8(d)) ;
v = [A(:), B(:), C(:), D(:)] ;