diff options
author | ttt | 2018-12-06 12:51:14 +0530 |
---|---|---|
committer | ttt | 2018-12-06 12:51:14 +0530 |
commit | 08123d6bb77e44a2078a04ca16a935c39e53cd42 (patch) | |
tree | eb8120dc6b8f0a900121ad608a183cb02ed3a389 /macros | |
parent | 7a00acd140266951804d52dd01bb78e05c906768 (diff) | |
download | FOSSEE-Signal-Processing-Toolbox-08123d6bb77e44a2078a04ca16a935c39e53cd42.tar.gz FOSSEE-Signal-Processing-Toolbox-08123d6bb77e44a2078a04ca16a935c39e53cd42.tar.bz2 FOSSEE-Signal-Processing-Toolbox-08123d6bb77e44a2078a04ca16a935c39e53cd42.zip |
code by jitendra
Diffstat (limited to 'macros')
-rw-r--r-- | macros/cceps.sci | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/macros/cceps.sci b/macros/cceps.sci index 3756a5d..f026256 100644 --- a/macros/cceps.sci +++ b/macros/cceps.sci @@ -5,26 +5,59 @@ function y = cceps (x,correct) //cceps(x, correct) //Parameters //x: vector. -//correct: if 1, a correction method is applied. +//correct: if 1, a correction method is applied. //Description //This function return the complex cepstrum of the vector x. If the optional argument correct has the value 1, a correction method is applied. The default is not to do this. //Examples //cceps([1,2,3],1) -//ans = -// 1.92565 -// 0.96346 -// -1.09735 +//ans = 1.9256506 + // 0.9634573 +// - 1.0973484 -funcprot(0); -rhs = argn(2) -if(rhs<1 | rhs>2) +if(argn(2)<1 | argn(2)>2) error("Wrong number of input arguments.") end + if argn(2)==1 then + correct=0; +end + + [r, c]=size(x) + if (c ~= 1) + if (r == 1) + x = x; + r = c; + else + error ("x must be a vector"); + end + end + + F = fft1(x); + if (min (abs (F)) == 0) + error ('bad signal x, some Fourier coefficients are zero.'); + end + h = fix (r / 2); + cor = 0; + if (2 * h == r) + cor = (c & (real (F (h + 1)) < 0)); + if (cor) + F = fft1 (x(1:r-1)) + if (min (abs (F)) == 0) + error ('bad signal x, some Fourier coefficients are zero.'); + end + end + end + y = fftshift1 (ifft1 ((log (F))')); + + //## make result real + if (c) + y = real (y); + if (cor) + // ## make cepstrum of same length as input vector + y (r) = 0; + end + end + - select(rhs) - case 1 then - y = callOctave("cceps",x) - case 2 then - y = callOctave("cceps",x,correct) - end endfunction + + |