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/zp2sos.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/zp2sos.sci')
-rw-r--r-- | macros/zp2sos.sci | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/macros/zp2sos.sci b/macros/zp2sos.sci new file mode 100644 index 0000000..6bb9426 --- /dev/null +++ b/macros/zp2sos.sci @@ -0,0 +1,51 @@ +function [sos,g] = zp2sos(z,p,k) +//This function converts filter poles and zeros to second-order sections. +//Calling Sequence +//[sos] = zp2sos(z) +//[sos] = zp2sos(z, p) +//[sos] = zp2sos(z, p, k) +//[sos, g] = zp2sos(...) +//Parameters +//z: column vector +//p: column vector +//k: real or complex value, default value is 1 +//Description +//This is an Octave function. +//This function converts filter poles and zeros to second-order sections. +//The first and second parameters are column vectors containing zeros and poles. The third parameter is the overall filter gain, the default value of which is 1. +//The output is the sos matrix and the overall gain. +//If there is only one output argument, the overall filter gain is applied to the first second-order section in the sos matrix. +//Examples +//zp2sos([1, 2, 3], 2, 6) +//ans = +// 6 -18 12 1 -2 0 +// 1 -3 0 1 0 0 + + +funcprot(0); +rhs = argn(2) +lhs = argn(1) +if(rhs<1 | rhs>3) +error("Wrong number of input arguments.") +end + select(rhs) + case 1 then + if (lhs<2) + sos=callOctave("zp2sos",z) + else + [sos,g]=callOctave("zp2sos",z) + end + case 2 then + if(lhs<2) + [sos]=callOctave("zp2sos",z,p) + else + [sos,g]=callOctave("zp2sos",z,p) + end + case 3 then + if(lhs<2) + sos=callOctave("zp2sos",z,p,k) + else + [sos,g]=callOctave("zp2sos",z,p,k) + end + end +endfunction |