Just to add to @ThijsW's answer, there is a significant speed advantage to the first method over the concatenation method:
big = 1e5; tic; x = rand(big,1); toc x = zeros(big,1); tic; for ii = 1:big x(ii) = rand; end toc x = []; tic; for ii = 1:big x(end+1) = rand; end; toc x = []; tic; for ii = 1:big x = [x rand]; end; toc Elapsed time is 0.004611 seconds. Elapsed time is 0.016448 seconds. Elapsed time is 0.034107 seconds. Elapsed time is 12.341434 seconds. I got these times running in 2012b however when I ran the same code on the same computer in matlab 2010a I get
Elapsed time is 0.003044 seconds. Elapsed time is 0.009947 seconds. Elapsed time is 12.013875 seconds. Elapsed time is 12.165593 seconds. So I guess the speed advantage only applies to more recent versions of Matlab