Dear all;
I have three data sets: This is just an example...
data1=[1 5 3 4 2 0 1 2 8 2 10 2 1];
data2=[1 10 ...
data3=[4 3 ...
I would like to sum by a step of 2 ,3 4 etc.. along data1 file. That means data1 becomes now:
data1_2 =[6 7 2 3 10 12]
data_3 =[9 6 11 14]
data_4 =[13 5 22]
data_5 =[15 13]
I did it and it works..
But I want to improve it to do the following:
Continue the sum calculation till the same length of the original data is reached. That means:
data1_2 =[6 7 2 3 10 12 12 10 3 2 7 6];
The result should be in case of summing 3 numbers for example like this:
data1_3=[9 6 11 14 13 12 3 12 9 6 1 14]
Here is my code:
##########################################
for i=1:1:length(data1);
step=floor(length(data1)./i);
for j=1:1:step
start_idx=i*(j-1)+1;
end_idx=i+start_idx-1;
Sum_data1(i,j)=sum(data1(start_idx:end_idx));
end
end
#################################
Thanks you gentlemen for your helps…
Cheers