summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandra Pratap2024-08-07 17:56:15 +0530
committerChandra Pratap2024-08-07 17:56:15 +0530
commit03da8216bd175e40c27fc4f0f81751a1fdc64ef5 (patch)
treeb79e4ab3f910893cfdb21dececc1161aa47610b3
parent93f9f93c60f05cb8e3349f1d967f30444dd338c4 (diff)
downloadFOSSEE-Signal-Processing-Toolbox-03da8216bd175e40c27fc4f0f81751a1fdc64ef5.tar.gz
FOSSEE-Signal-Processing-Toolbox-03da8216bd175e40c27fc4f0f81751a1fdc64ef5.tar.bz2
FOSSEE-Signal-Processing-Toolbox-03da8216bd175e40c27fc4f0f81751a1fdc64ef5.zip
Implement triang.sci in Scilab
-rw-r--r--macros/triang.sci14
1 files changed, 13 insertions, 1 deletions
diff --git a/macros/triang.sci b/macros/triang.sci
index f450d97..596bfab 100644
--- a/macros/triang.sci
+++ b/macros/triang.sci
@@ -6,7 +6,6 @@ function w = triang (m)
//m: positive integer value
//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.
//Examples
//triang(5)
@@ -29,3 +28,16 @@ rhs = argn(2)
w = 1 - abs ([-(m-1):2:(m-1)]' / (m+modulo(m,2)));
endfunction
+
+//test input validation:
+//assert_checkerror("triang()", "Wrong number of input arguments.");
+//assert_checkerror("triang(1, 2)", "Wrong number of input arguments.");
+//assert_checkerror("triang(0.5)", "parzenwin: M must be a positive integer");
+//assert_checkerror("triang(-1)", "parzenwin: M must be a positive integer");
+//assert_checkerror("triang(zeros (2, 5))", "parzenwin: M must be a positive integer");
+
+//tests:
+//assert_checkequal(triang(1), 1);
+//assert_checkequal(triang(2), [1; 1]/2);
+//assert_checkequal(triang(3), [1; 2; 1]/2);
+//assert_checkequal(triang(4), [1; 3; 3; 1]/4);