summaryrefslogtreecommitdiff
path: root/macros/bohmanwin.sci
diff options
context:
space:
mode:
Diffstat (limited to 'macros/bohmanwin.sci')
-rw-r--r--macros/bohmanwin.sci45
1 files changed, 22 insertions, 23 deletions
diff --git a/macros/bohmanwin.sci b/macros/bohmanwin.sci
index 183637c..8f391c8 100644
--- a/macros/bohmanwin.sci
+++ b/macros/bohmanwin.sci
@@ -1,27 +1,26 @@
-function y = bohmanwin (m)
-//This function returns the filter coefficients of a Bohman window.
-//Calling Sequence
-//y = bohmanwin (m)
-//Parameters
-//m: positive integer value
-//y: output variable, vector of real numbers
-//Description
-//This is an Octave function.
-//This function returns the filter coefficients of a Bohman window of length m supplied as input, to the output vector y.
-//Examples
-//bohmanwin(4)
-//ans =
-// 0.
-// 0.6089978
-// 0.6089978
-// 0.
+function w = bohmanwin (m)
-rhs = argn(2)
+ funcprot(0);
+ rhs= argn(2);
-if(rhs~=1)
-error("Wrong number of input arguments.")
-end
+ if (rhs ~= 1)
+ error("Wrong Number of input arguments");
+ end
-y = callOctave("bohmanwin",m)
+ if (~ (isscalar (m) & (m == fix (m)) & (m > 0)))
+ error ("bohmanwin: M must be a positive integer");
+ end
-endfunction
+ if (m == 1)
+ w = 1;
+ else
+ N = m - 1;
+ n = -N/2:N/2;
+
+ w = (1-2.*abs(n)./N).*cos(2*%pi.*abs(n)./N) + (1/%pi).*sin(2*%pi.*abs(n)./N);
+ w(1) = 0;
+ w(length(w))=0;
+ w = w';
+ end
+
+endfunction