Prev: XBEE with matalb
Next: ADX, +DI, -DI, parabolic SAR
From: someone on 23 Jun 2010 09:34 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.
From: Oleg Komarov on 23 Jun 2010 10:17 "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
From: someone on 23 Jun 2010 10:33 "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
From: us on 23 Jun 2010 10:46 "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
From: Oleg Komarov on 23 Jun 2010 12:13
"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 |