diff options
author | shamikam | 2017-11-07 15:59:48 +0530 |
---|---|---|
committer | shamikam | 2017-11-07 15:59:48 +0530 |
commit | c0c0582462720ed597b00e116506570577614e89 (patch) | |
tree | 31dedd23698e5357b19c810b7d7a8464100ef44a /macros/decimate.sci | |
download | FOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.tar.gz FOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.tar.bz2 FOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.zip |
initial commit
Diffstat (limited to 'macros/decimate.sci')
-rw-r--r-- | macros/decimate.sci | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/macros/decimate.sci b/macros/decimate.sci new file mode 100644 index 0000000..5a2e428 --- /dev/null +++ b/macros/decimate.sci @@ -0,0 +1,47 @@ +function y = decimate(x, q, n, ftype) +rhs = argn(2) +if(rhs<2 | rhs>4) +error("Wrong number of input arguments.") +elseif(~(sum(length(q)==1) & q == fix (q) & q > 0)) +error("Parameter 2 must be a positive integer.") +end +if (nargin < 3) +ftype = "iir" +n = [] +elseif (nargin < 4) +if (ischar (n)) +ftype = n +n = [] +else +ftype = "iir" +end +end + +if (~ and(strcmp (ftype, {"fir", "iir"}))) +error("Filter type must be either fir or iir.") +end + +fir = strcmp (ftype, "fir") +if (isempty (n)) +if (fir) +n = 30 +else +n = 8 +end +end + +if(~(sum(length(n)==1) & n == fix (n) & n > 0)) +error("N must be a positive integer.") +end +select(rhs) +case 2 then +y = callOctave("decimate", x, q) +case 3 then +y = callOctave("decimate", x, q, n) +case 4 then +y = callOctave("decimate", x, q, n, ftype) +end +endfunction + + + |