So, in order to change row as you change the q, you have to change the range dynamically.
row_num = 1;
Range = ['A',num2str(row_num)];
But it will only affect the performance of your code. So, what I suggest is that you store all the q array in a "master" array dynamically
i = 1;
master_data(i,:) = q;
and save that master array in the Excel file at the end of the code using :