summaryrefslogtreecommitdiff
path: root/macros/parzenwin.sci
diff options
context:
space:
mode:
authorSunil Shetye2018-07-25 17:11:09 +0530
committerSunil Shetye2018-07-26 23:50:17 +0530
commit1251f70aa3442736ce6fd9c4fb7fbce412af5a52 (patch)
tree360311ffaf6151c5066439f481e8ac38cfd047b9 /macros/parzenwin.sci
parent9ca7882cee16ad48b18df989e8300c697010e55a (diff)
downloadFOSSEE-Signal-Processing-Toolbox-1251f70aa3442736ce6fd9c4fb7fbce412af5a52.tar.gz
FOSSEE-Signal-Processing-Toolbox-1251f70aa3442736ce6fd9c4fb7fbce412af5a52.tar.bz2
FOSSEE-Signal-Processing-Toolbox-1251f70aa3442736ce6fd9c4fb7fbce412af5a52.zip
code changes by Kartik Hegde during FOSSEE Fellowship 2018
Diffstat (limited to 'macros/parzenwin.sci')
-rw-r--r--macros/parzenwin.sci36
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