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/sos2ss.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/sos2ss.sci')
-rw-r--r-- | macros/sos2ss.sci | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/macros/sos2ss.sci b/macros/sos2ss.sci new file mode 100644 index 0000000..c13f688 --- /dev/null +++ b/macros/sos2ss.sci @@ -0,0 +1,44 @@ +//Author: Parthasarathi Panda +//parthasarathipanda314@gmail.com +function [A,B,C,D]=sos2ss(sos,g) + [nargout,nargin]=argn(); + if nargin==1 then + g=1; + end + if type(sos)~=1 | type(g)~=1 then + error('check the data type of input'); //to check if the inputs are real/complex arrays + end + if size(g)~=[1,1] then + error('check the data type of input'); //to check that n is single dimensional + end + //checking if sos is a 6 column matrix + [d,j]=size(sos); + if j~=6 then + error('sos should be a 6-column matrix'); + end + + num=[1]; + den=[1]; + //convolving the numerator and denominator to get the coefficient of the numerator and the denominator at the top and bottom + for i=[1:d] + num=convol(num,sos(i,1:3)); + den=convol(den,sos(i,4:6)); + end + + if den(t)==0 then + error('improper transfer function check input'); + end + + t=2*d+1; //polynomial degree + A=zeros(t-1,t-1); + if t>2 then + A(2:(t-1),1:(t-2))=eye(t-2,t-2); + end + A(1,:)=-1*den(2:t)/den(1); + B=zeros(t,1); + B(1)=1/den(1); //constructing (A,B) in canonical controllable form + + C=g*(num(2:t)-den(2:t)*num(1)/den(1));//appropiate C and D + D=g*num(1)/den(1); + +endfunction |