From 9ca7882cee16ad48b18df989e8300c697010e55a Mon Sep 17 00:00:00 2001 From: Sunil Shetye Date: Wed, 25 Jul 2018 16:27:51 +0530 Subject: code changes by Sonu Sharma during FOSSEE Fellowship 2018 --- macros/cheb2ap.sci | 94 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 36 deletions(-) (limited to 'macros/cheb2ap.sci') diff --git a/macros/cheb2ap.sci b/macros/cheb2ap.sci index 007d2d5..a599f31 100644 --- a/macros/cheb2ap.sci +++ b/macros/cheb2ap.sci @@ -1,39 +1,61 @@ -function [z, p, g] = cheb2ap (n, Rs) -//This function designs a lowpass analog Chebyshev type II filter. -//Calling Sequence -//[z, p, g] = cheb2ap (n, Rs) -//[z, p] = cheb2ap (n, Rs) -//p = cheb2ap (n, Rs) -//Parameters -//n: Filter Order -//Rs: Stopband attenuation -//z: Zeros -//p: Poles -//g: Gain -//Description -//This is an Octave function. -//This function designs a lowpass analog Chebyshev type II filter of nth order and with a stopband attenuation of Rs. -//Examples +// 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:Sonu Sharma, RGIT Mumbai +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function [z, p, g] = cheb2ap (n, Rs) + //This function produces a lowpass analog Chebyshev type II prototype filter. + + //Calling Sequence + //[z, p, g] = cheb2ap (n, Rs) + + //Parameters + //n: Filter Order + //Rs: Stopband attenuation (in dB) + //z: Zeros + //p: Poles + //g: Gain + + //Description + //This function designs a lowpass analog Chebyshev type II filter of nth order and with a stopband attenuation of Rs. + + //Examples + //[z, p, g] = cheb2ap (4, 10) + //Output : + // g = + // + // 0.3162278 + // p = + // + // - 0.1674887 + 0.9498949i + // - 1.1818323 + 1.1499912i + // - 1.1818323 - 1.1499912i + // - 0.1674887 - 0.9498949i + // z = + // + // - 1.0823922i + // - 2.6131259i + // 2.6131259i + // 1.0823922i + + + funcprot(0); + lhs = argn(1) + rhs = argn(2) + if (rhs < 2 | rhs > 2) + error("cheb2ap: Wrong number of input arguments.") + end -funcprot(0); -lhs = argn(1) -rhs = argn(2) -if (rhs < 2 | rhs > 2) -error("Wrong number of input arguments.") -end - -select(rhs) - - case 2 then - if(lhs==1) - z = callOctave("cheb2ap", n, Rs) - elseif(lhs==2) - [z, p] = callOctave("cheb2ap", n, Rs) - elseif(lhs==3) - [z, p, g] = callOctave("cheb2ap", n, Rs) - else - error("Wrong number of output argments.") - end - end + Rsf = 10 ^ (-Rs/20); //stop band pick to pick ripple in fraction + rs = Rsf ; //analpf function compitable stop band ripple (delta-s) + [hs,p,z,g]=analpf(n,"cheb2",[0 rs],1); //cutoff frequency of 1 rad/sec for prototype filter + p = p' ; + z = z' ; + g = abs(g); endfunction -- cgit