diff options
-rw-r--r-- | macros/ss2sos.sci | 48 | ||||
-rw-r--r-- | test3.sce | 46 |
2 files changed, 52 insertions, 42 deletions
diff --git a/macros/ss2sos.sci b/macros/ss2sos.sci index 2664b24..09ae366 100644 --- a/macros/ss2sos.sci +++ b/macros/ss2sos.sci @@ -1,25 +1,35 @@ -//Author: Parthasarathi Panda -//parthasarathipanda314@gmail.com +// Copyright (C) 2018 - IIT Bombay - FOSSEE +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Author: Parthasarathi Panda , < parthasarathipanda314@gmail.com> +// Modifieded by: Abinash Singh Under FOSSEE Internship +// Date of Modification: 4 Apr 2024 +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + //ss2sos converts a state-space representation of a given digital filter to an equivalent second-order section representation. ////Example: -//a =[0.5095,0,0,0,0; -//0.3007, 0.2260, -0.3984, 0, 0; -//0.0977, 0.3984, 0.8706, 0, 0; -//0.0243, 0.0991, 0.4652, 0.5309, -0.4974; -//0.0079, 0.0322, 0.1512, 0.4974, 0.8384]; -// -// -//b =[0.6936 0.1382 0.0449 0.0112 0.0036]' -// -// -//c =[0.0028 0.0114 0.0534 0.1759 0.6500] -// -// -//d =0.0013 +// a =[0.5095,0,0,0,0; +// 0.3007, 0.2260, -0.3984, 0, 0; +// 0.0977, 0.3984, 0.8706, 0, 0; +// 0.0243, 0.0991, 0.4652, 0.5309, -0.4974; +// 0.0079, 0.0322, 0.1512, 0.4974, 0.8384]; + + +// b =[0.6936 0.1382 0.0449 0.0112 0.0036]' + + +// c =[0.0028 0.0114 0.0534 0.1759 0.6500] + + +// d =0.0013 -//[sos,g]=ss2sos(a,b,c,d) +// [sos,g]=ss2sos(a,b,c,d) //Expected output: //g = // 0.0013 @@ -60,8 +70,8 @@ function [sos,g]=ss2sos(A,B,C,D) //obtaining the transfer function(continuous) tf=ss2tf(syslin('c',A,B,C,D)); //factorising the numerator and the denominator into second order systems - [zero,gn]=sosbreak(numer(tf));//function is defined in the same folder - [pole,gd]=sosbreak(denom(tf)); + [zero,gn]=sosbreak(tf.num);//function is defined in the same folder + [pole,gd]=sosbreak(tf.den); //reducing each pair of second order in the necessary form sos=[]; for i=[1:length(pole)] @@ -486,38 +486,38 @@ else disp("test failed for upsample fill"); end -///////////test for ss2sos/////////////// test disabled - numer,denom not defined in scilab 2025.0.0 however according to docs , it should be available -// a =[0.5095,0,0,0,0; -// 0.3007, 0.2260, -0.3984, 0, 0; -// 0.0977, 0.3984, 0.8706, 0, 0; -// 0.0243, 0.0991, 0.4652, 0.5309, -0.4974; -// 0.0079, 0.0322, 0.1512, 0.4974, 0.8384]; +///////////test for ss2sos/////////////// +a =[0.5095,0,0,0,0; +0.3007, 0.2260, -0.3984, 0, 0; +0.0977, 0.3984, 0.8706, 0, 0; +0.0243, 0.0991, 0.4652, 0.5309, -0.4974; +0.0079, 0.0322, 0.1512, 0.4974, 0.8384]; -// b =[0.6936 0.1382 0.0449 0.0112 0.0036]'; +b =[0.6936 0.1382 0.0449 0.0112 0.0036]'; -// c =[0.0028 0.0114 0.0534 0.1759 0.6500]; +c =[0.0028 0.0114 0.0534 0.1759 0.6500]; -// d =0.0013; +d =0.0013; -// a=roundn(a,3); -// b=roundn(b,3); -// c=roundn(c,3); -// d=roundn(d,3); +a=roundn(a,3); +b=roundn(b,3); +c=roundn(c,3); +d=roundn(d,3); -// [sos,g]=ss2sos(a,b,c,d); -// e=[0.509,0,0,0,0;0.301,0.226,-0.398,0,0;0.098,0.398,0.871,0,0;0.024,0.099,0.465,0.531,-0.497;0.008,0.032,0.151,0.497,0.838 ]; +[sos,g]=ss2sos(a,b,c,d); +e=[0.509,0,0,0,0;0.301,0.226,-0.398,0,0;0.098,0.398,0.871,0,0;0.024,0.099,0.465,0.531,-0.497;0.008,0.032,0.151,0.497,0.838 ]; -// if(g==0.001) -// if (a==e) then -// test_pass=[test_pass 1]; -// end -// else -// test_pass=[test_pass,0]; -// disp("test failed for ss2sos"); -// end +if(g==0.001) + if (a==e) then + test_pass=[test_pass 1]; + end +else + test_pass=[test_pass,0]; + disp("test failed for ss2sos"); +end ///////////////test for upfirdn///////////// |