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); endend
Best Answer