From: Aaron on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <9332b8ef-b2f0-4c9b-a937-206284eb069c(a)y4g2000yqy.googlegroups.com>...
> Try calling reshape to make it 260 columns wide instead of 26, then
> call mean().
> By the way, your matrix is not a multiple of 10 rows, so you may have
> to do special things for the last 9 rows..

I'm guessing the reshape with padded columns is to make the columns a multiple of 10, but I think by calling mean() after that I am still going to end up with only the mean of each whole column (mean of ~27k data points). Whereas, I need it to take the mean of every 10 rows condensing the data down to 1/10 the rows by averaging 10 rows as it goes. I tried to do a huge nested for loop but it just throws me an out of memory error since it's doing way to much recursion...

for m=1:26 %# of columns to process
for n=1:10:length(data) %n0=1, n1=11,n2=21,etc.
y(n,m)=1/10*(data(n,m)+data(n-1,m)+data(n-2,m)+data(n-3,m)+data(n-4,m)+data(n-5,m)+data(n-6,m)+data(n-7,m)+data(n-8,m)+data(n-9,m))
end
end
From: someone on
"Aaron " <aaron.stender(a)honeywell.com> wrote in message <i1fk3h$ahr$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <i1f7ob$qi7$1(a)fred.mathworks.com>...
> > "Aaron " <aaron.stender(a)honeywell.com> wrote in message <i1f78s$oae$1(a)fred.mathworks.com>...
> > > I currently have a data matrix that is 27359x26. This data is all taken at 1 minute intervals, but the time will be variable between different data sets I will be running this script on, so the 27359 will be variable depending on total test time. I am looking to get the average of every 10 rows but cannot seem to figure it out. ie - condense the 1 minute data to 10 minute data by taking every 10 rows and averaging them 1-10,11-20,21-30,etc...)
> > >
> > > Any help would be greatly appreciated.
> >
> > a hint:
> >
> > help filter;
> >
> > us
>
> I've searched and searched but I can't seem to figure out how to use the filter function to my advantage. It seems to me in every example I've found that it is doing a running average (sliding window) whereas I am looking for a simple moving average of 10 seperate points at a time (1-10,11-20,21-30, etc...). Any more hints? I am trying to condense my 27359 data points down by a factor of 10 to 2736 (the last set would only include the average of the last 9 points instead of 10 like the rest then).
>
> Thanks for the help.

Q. What is the difference between "a simple moving average of 10 separate points at a time" and "a running average" and only looking at every 10th point?

A. None.
From: Jan Simon on
Dear Aaron,

> I currently have a data matrix that is 27359x26. This data is all taken at 1 minute intervals, but the time will be variable between different data sets I will be running this script on, so the 27359 will be variable depending on total test time. I am looking to get the average of every 10 rows but cannot seem to figure it out. ie - condense the 1 minute data to 10 minute data by taking every 10 rows and averaging them 1-10,11-20,21-30,etc...)

All you need has been mentioned already, except for the ready-to-copy solution. Ok. Try this:
data = rand(27359, 26); % Arbitrary test data
A = mean(reshape(data(1:27350, :), [2735, 10, 26]), 2);
A = reshape(A, [2735, 26]);
Decide what you want to do with the last 9 frames. Use REM to determine a mutliple of 10:
x = 27359;
x_multOf10 = x - rem(x, 10);

Averaging blocks has been discussed often here. See also:
http://www.mathworks.com/matlabcentral/fileexchange/24812

Good luck, Jan
From: Aaron on
Thanks for the suggestions to everyone. I really do appreciate the help this board provides. I ended up figuring out a nested for loop that will work for me based on differing lengths of the input vector. Just took me awhile to get my math hat on to think about this versus trying to use a built in function in Matlab. Here's the code I came up with:

for m=1:26,
for n=1:10:(floor(length(data)/10)*10),
y(floor(n/10)+1,m)=mean(data(n:n+9,m));
end
end

This will then fill the vector y with the mean of every consecutive 10 rows for the full 26 columns condensing the data by 10. Now to figure out how to deal with the remaining points that get truncated at the end of the data file. Shouldn't be too difficult to figure that out now.

Thanks again.
From: us on
"Aaron " <aaron.stender(a)honeywell.com> wrote in message <i1fk3h$ahr$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <i1f7ob$qi7$1(a)fred.mathworks.com>...
> > "Aaron " <aaron.stender(a)honeywell.com> wrote in message <i1f78s$oae$1(a)fred.mathworks.com>...
> > > I currently have a data matrix that is 27359x26. This data is all taken at 1 minute intervals, but the time will be variable between different data sets I will be running this script on, so the 27359 will be variable depending on total test time. I am looking to get the average of every 10 rows but cannot seem to figure it out. ie - condense the 1 minute data to 10 minute data by taking every 10 rows and averaging them 1-10,11-20,21-30,etc...)
> > >
> > > Any help would be greatly appreciated.
> >
> > a hint:
> >
> > help filter;
> >
> > us
>
> I've searched and searched but I can't seem to figure out how to use the filter function to my advantage. It seems to me in every example I've found that it is doing a running average (sliding window) whereas I am looking for a simple moving average of 10 seperate points at a time (1-10,11-20,21-30, etc...). Any more hints? I am trying to condense my 27359 data points down by a factor of 10 to 2736 (the last set would only include the average of the last 9 points instead of 10 like the rest then).
>
> Thanks for the help.

one of the many solutions

flen=3;
v=[1,1,1,2,2,2,3,3,3,4,4,4,5,5,5];
r=filter(ones(1,flen),1,v);
r=r(flen:flen:end)./flen
% r = 1 2 3 4 5

us