MATLAB: Concatenate

convertfor loopiterationmatrix array

I have a for-loop that executes commands and displays the answer for each iteration. Please, can someone tell me how to concatenate all the answers into an array instead of having the results displayed independently for each iteration. cheers.

Best Answer

Paulo answered the question as you phrased it, but if you know the exact number of results you are producing (or if the maximum number of results is "reasonably close" to the likely number of results), then you are better off pre-allocating memory for the results:
a = zeros(10,1);
for b = 1:10
a(b) = 3*b+5; %for example
end
When you get to thousands of elements, pre-allocating can be much much faster.