diff options
Diffstat (limited to 'macros/parzenwin.sci')
-rw-r--r-- | macros/parzenwin.sci | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/macros/parzenwin.sci b/macros/parzenwin.sci index f51c924..c8944af 100644 --- a/macros/parzenwin.sci +++ b/macros/parzenwin.sci @@ -1,26 +1,38 @@ -function [y] = parzenwin (m) +function w = parzenwin (m) //This function returns the filter coefficients of a Parzen window. //Calling Sequence -//y = parzenwin (m) -//Parameters +//w = parzenwin (m) +//Parameters //m: positive integer value -//y: output variable, vector of real numbers +//w: output variable, vector of real numbers //Description //This is an Octave function. -//This function returns the filter coefficients of a Parzen window of length m supplied as input, to the output vector y. +//This function returns the filter coefficients of a Parzen window of length m supplied as input, to the output vector y. //Examples //parzenwin(3) //ans = -// 0.0740741 -// 1. // 0.0740741 +// 1. +// 0.0740741 + + funcprot(0); + rhs= argn(2); -rhs = argn(2) + if (rhs ~= 1) + error("Wrong Number of input arguments"); + elseif (~ (isscalar (m) & (m == fix (m)) & (m > 0))) + error ("parzenwin: M must be a positive integer"); + end -if(rhs~=1) -error("Wrong number of input arguments.") -end + N = m - 1; + n = -(N/2):N/2; + n1 = n(find(abs(n) <= N/4)); + n2 = n(find(n > N/4)); + n3 = n(find(n < (-N/4))); -y = callOctave("parzenwin",m) + w1 = 1 -6.*(abs(n1)./(m/2)).^2 + 6*(abs(n1)./(m/2)).^3; + w2 = 2.*(1-abs(n2)./(m/2)).^3; + w3 = 2.*(1-abs(n3)./(m/2)).^3; + w = [w3 w1 w2]'; endfunction |