i am wondering if anybody has suggestions how to implement the following problem:
i have around 600 data points that were collected over time (50ms intervals). The first part of the timeseries is most important for the analysis. I therefore would like to bin the data in a way that over time more and more time-points are binned and therefore the measurements averaged. For example:
Datapoints to average:
1
2-3
4-6
7-10
11-15
Is there a way to do this automatically?
Thanks a lot for your suggestions,
Philipp
logspace() to get the boundaries. histc() the times against those boundaries,
throwing away the bin counts and keeping the indices. accumarray() using the
indices as the bin numbers and the sample values as the values to accumulate,
and using @mean as the optional function to apply to the accumulated values.
Thank you,
Philipp
Walter Roberson <robe...@hushmail.com> wrote in message <ic6oqb$suu$1...@canopus.cc.umanitoba.ca>...
N bins, times from 1 to maxT, data in SampleValues
[unused, binidx] = histc(1:maxT,logspace(log10(1),log10(maxT),N+1));
means = accumarray(binidx.', SampleValues(:), [], @mean);
thank you for your help and sorry for my late response. I was able to use your solution and modified it slightly for my purposes. Now I am wondering if you could help me with one more thing:
Thats my function:
function [ logtime logdata ] = LogBinData( time, data, bins )
spacing=logspace(log10(1),log10(length(time)+1),bins);
[~, binidx] = histc(1:length(time),spacing);
timemeans = accumarray(binidx.', time', [], @mean);
if time(1)==0,
logtime=[0; timemeans(timemeans~=0)];
else
logtime=timemeans(timemeans~=0);
end
datameans = accumarray(binidx.', data', [], @mean);
logdata=datameans(datameans~=0);
end
If I provide let say 550 datapoints and chose to do the logspace with bins=100 I will end up with 71 log-binned data point.
Thats all right. If my data changes, and I want to bin let say 750 datapoint I would like to get a solution that corresponds to the previous binning of 550 datapoints but just goes beyond that. How could I achieve this? I am not quite clear about the relation of my variable bins that determines the spacing and the number of bins that I end up after getting rid of the zero values.
I would be really thankful for any advice.
Thanks a lot,
Philipp
Walter Roberson <robe...@hushmail.com> wrote in message <ic6uek$85c$1...@canopus.cc.umanitoba.ca>...