MATLAB: How to count non-zero elements in a column but over a specified range

cell arraysumzero

I'm trying to get the sum of non-zero elements in a column and store these values. The column consists of a list of numbers that range from 1 to 5000 and then repeats again 1 to 5000. I'm trying to count the number of non-zero elements in one range (from 1 to 5000), store this value, and then move onto the next range of 1 to 5000, store this value etc.
I've tried the following:
store_sum = zeros(length(list_values));
for i = 1:length(list_values)
for j = 0:5000
store_sum = sum( i ~= 0,1);
end
end

Best Answer

This may be what you want, but your description of the problem is very hard to interpret. You just want the number of non-zero elements in each column of true_spike?
store_sum = sum(true_spike>0)