As the code appears in your question, you are overwriting S in every loop.
Assuming you don't have a length mismatch as Sara pointed out, that line should read like this:
depending on whether t is a column or row vector.
You probably will have a length mismatch since number of spikes and spike times are pseudo random, so you will either need to follow Sara's advice to use a cell array or preallocate an array of NaN's at some number larger than the number of spikes you expect x 50. Saving t into S would then look like this:
S = nan(10000,50);
S(1:numel(t),i) = t;