[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vectorization
From: |
David Bateman |
Subject: |
Re: vectorization |
Date: |
Thu, 17 Jul 2008 01:01:36 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (Windows/20060909) |
David Bateman wrote:
The final reshape should use size(a) and not size(A).. Thus the code
function q = newfilter1 (A, npoints)
% assumes A is a muliple of npoints long
a = reshape (A, npoints, numel(A) / npoints);
q = reshape (repmat (min (abs(A - repmat(mean (A, 1), npoints, 1)),
1), npoints, 1), size (a));
endfunction
should be used instead. Untested as is the previous code.
D.
Sorry take 3.
function q = newfilter (A, npoints)
% assumes A is a muliple of npoints long
a = reshape (A, npoints, numel(A) / npoints);
[dum, idx] = min (abs(a - repmat(mean (a, 1), npoints, 1)), [], 1)
q = reshape (repmat (a(idx + [0 : numel(A) / npoints - 1] * ...
npoints), npoints, 1), size (A));
endfunction
Bit hard to test the code at the moment due to lack of a copy of Octave,
which explains the number of attempts to get it right
D.