A(i,:) = Y;
Don't Forget To Preallocates Your Matrix:
A = zeros(n, m);
Where n Would Be The Number Of Rows ( Iterations) And m Is The Length Of The Rows (5 In Your Example)
Another Approach Is To Concat The Rows At The End Of He Matrix:
A = [A;Y];
This Would Reallocate The Entire Matrix Each Iteration, so For Larger Datasets It Would Take Forever, so It's Better To Avoid This Practice.
Asfor Not Finding An Example, https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html