summaryrefslogtreecommitdiff
path: root/macros/triang.sci
diff options
context:
space:
mode:
Diffstat (limited to 'macros/triang.sci')
-rw-r--r--macros/triang.sci31
1 files changed, 17 insertions, 14 deletions
diff --git a/macros/triang.sci b/macros/triang.sci
index 6bbca69..f450d97 100644
--- a/macros/triang.sci
+++ b/macros/triang.sci
@@ -1,28 +1,31 @@
-function [y] = triang (m)
+function w = triang (m)
//This function returns the filter coefficients of a triangular window.
//Calling Sequence
-//y = triang (m)
-//Parameters
+//w = triang (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 triangular window of length m supplied as input, to the output vector y.
+//This function returns the filter coefficients of a triangular window of length m supplied as input, to the output vector y.
//Examples
//triang(5)
//ans =
-// 0.3333333
-// 0.6666667
-// 1.
-// 0.6666667
-// 0.3333333
+// 0.3333333
+// 0.6666667
+// 1.
+// 0.6666667
+// 0.3333333
funcprot(0);
rhs = argn(2)
-if(rhs~=1)
-error("Wrong number of input arguments.")
-end
-y = callOctave("triang",m)
+ 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
+
+ w = 1 - abs ([-(m-1):2:(m-1)]' / (m+modulo(m,2)));
endfunction