If you concatenate two column vectors horizontally:
a = rand(5, 1);
b = rand(5, 1);
c = [a, b]
the contiguos blocks of memory are joined, because Matlab stores the data in columnwise order. In opposite to this, the vertical concatenation:
a = rand(1, 5);
b = rand(1, 5);
c = [a; b]
creates the output by copying one element after the otehr from both vectors, which is less efficient.
These effects are much more important than the question if you use [,] or horzcat. As far as I remember, a profiling with -detail builtin revealed in older Matlab versions, that for [,] the function horzcat is called internally, but I could not reproduce this in R2016b.
For measuring run times prefer either timeit or call the operation in a loop inside the tic/toc to increase the accuracy.
If the brackets are some micro seconds faster or slower than the cat functions, this might change with the next Matlab version. Therefore I would not concentrate on this detail, but use the method, which is better to read: The total time to solve a problem includes the time for programming, debugging and maintenance of the code also. "Premature optimization" is a common pitfall and you find some tutorials, if you search for this term in the net.
Best Answer