MATLAB: Storing values from nested FOR loop (array only saves last run of results)

arrayconcatenate arrayfor loopMATLABnestedstore values in array

Hi guys, have tried searching but can't find anything to help, maybe my problem is too simple! lol Anyway, I'm running a nested FOR loop, but the array I save my results to only keeps the last "run" of results. Can someone please help me to store/concatenate the results in a single array? EG the resultant array should have 12 rows, not 4. with column one going 1,2,3,4,1,2,3,4,1,2,3,4 and column two going 10,10,10,10,20,20,20,20,30,30,30,30.
Cheers in advance! (first line currently commented out as the last 8 rows stay zero at the minute)
%tableA = zeros(12,2);
for i=1:4
for j=1:3
answerA=i*1
answerB=j*10
tableA(i,:)=[answerA answerB]
end
end
P.S. this isn't the real code I'm using, but a dumbed down version just so I can get the correct syntax to use to apply to the bigger problem! Cheers.

Best Answer

for i=1:4
for j=1:3
answerA(i,j)=i*1;
answerB(i,j)=j*10;
% tableA(i,:)=[answerA answerB]
end
end
table=[reshape(answerA,[],1) reshape(answerB,[],1)]