Not sure what format you want but if you want all the red values then all the green values and then all the blue values you can do this:
[r,g,b] = imsplit(rgbImage);
vec = [r(:); g(:); b(:)];
If you want in a matrix with the x,y,r,g,b (one pixel per row), then see the attached code.