Difficult to answer without more context, but I suspect that the error is not related to the loops but something else. There are other points that whilst not errors, will not work:
for selaMasa = 1: length(TempMatrix)
tempSela = zeros(12502,1);
tempSela = tempSela + 4;
hold on
end
In this case, every time you enter the loop, you initialise your variable tempSela to zeros, then add four. So, no matter how many times you iterate inside the loop, the answer will always be 4 for every value of tempSela. You could simply do the following:
tempSela = zeros(12502,1) + 4*length(TempMatrix);
In addition, hold on is used when you create a figure, plot something that you want to keep and then plot something else. In this case it is not necessary.
Hope this helps.