Rebinning values and for loops
Show older comments
I am trying to rebin 30 values into 1 using for loops but am running into trouble. I am trying to do the sum of 30 values --> put into cell 1, then sum the next 30 values --> put into cell 2 and so on. In other words, I am trying to do this:
secdist(1,1) = sum(framedist(1:30));
secdist(2,1) = sum(framedist(31:61));
secdist(3,1) = sum(framedist(62:92))
Here is my code:
nbins=ceil(s/30); %number of bins. Grouping of 30 values (=1second) into 1 bin
secdist= zeros(nbins,1);
for i2=1:nbins, i=1:31:(s-30);
secdist(i2,1) = sum(framedist(i:(i+30))); %%sum of distance over 30 poses (1second) -- not working
end
However, this is not working like I would like. Does anyone have any idea how I could do this?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!