Prev: XBEE with matalb
Next: ADX, +DI, -DI, parabolic SAR
From: Jan Simon on 23 Jun 2010 12:14 Dear Richard! Another approach is the Mex function BlockMean: http://www.mathworks.com/matlabcentral/fileexchange/24812 Good luck, Jan
From: someone on 23 Jun 2010 16:21 "Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <hvtbqg$3l4$1(a)fred.mathworks.com>... > "us " <us(a)neurol.unizh.ch> wrote in message <hvt6nr$qvu$1(a)fred.mathworks.com>... > > "someone" <someone(a)somewhere.net> wrote in message <hvt5v0$690$1(a)fred.mathworks.com>... > > > "Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <hvt510$46l$1(a)fred.mathworks.com>... > > > > "someone" <someone(a)somewhere.net> wrote in message <hvt2gc$g6e$1(a)fred.mathworks.com>... > > > > > ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <f4cef6bf-06a0-4317-94a7-927c35aa82df(a)c33g2000yqm.googlegroups.com>... > > > > > > Richard: > > > > > > An alternative method that you may find handy sometime is > > > > > > blockproc(). With that you can also use a much more complicated > > > > > > function than a simple average. > > > > > > > > > > Still another possibility is the filter function. > > > > > > > > > > doc filter > > > > > > > > > > and look at the Example section to find a running average. > > > > > > > > This is not a running average (or how it would be possible to achieve the same result with the filter function, my personal interest thanks) > > > > > > > > Oleg > > > > > > Take us's solution: > > > v=[1 2 6 2 1 4 6 2 6 8 5 2].'; > > > r=mean(reshape(v,[],2)) > > > % r = 2.6667 4.8333 > > > > > > Now, another way to get us's solution with the filter function is: > > > ra = filter(ones(1,6)/6,1,v); > > > ra(6:6:end) > > > > > > ans = > > > > > > 2.6667 > > > 4.8333 > > > > yes, fully agree: there's nothing wrong with a FILTER approach... > > > > us > I thought of this approach but isn't it more expensive than reshaping? I mean you take just some values from ra (it's like doing diag(A*B) instead of sum(A.*(B).',2) where A and B are square matrices of the same size). > > Oleg Yes, it may be the more "expensive" approach. On the other hand, if you wanted the average of ANY 6 consecutive sequences, or wanted the true running average, then you have it.
From: Richard Wylde on 7 Jul 2010 12:25
Hello all, Apologies to re-open such an old message. I had solved this problem, for a small data set. However, now I have a dataset which has well over a million entries. My code is: % 22nd June 2010 % Function to average data invariable = input('Enter variable name: '); insize = size(invariable); numinsize = insize(1); period = input('Enter current data interval (seconds): '); time = input('Enter period to average data over (seconds): '); divider = time/period; averagev = mean(reshape(invariable,divider,[])); finalv = averagev' And when I run this, I get an output with the number of rows as expected. However, the values are much too high. Does anyone know why? |