The 1st time I heard of Scilab, this is what i had on my mind ! A Science Lab ....
(P.S: If anyone of you stumbled this code, you may
And BTW, this code can "run" on Scilab ver 5.2.2 just fine... If you had downloaded my scilab toolboxes... :P)
====================Start Copy From Here========================
//The analog prototype filter specifications
clc ; //Clean the previous console commands
wp = 0.2*%pi;
ws = 0.3*%pi;
Rp = 1;
Rs = 15;
Fs = 0.5;
T = 1/Fs;
//Prewarped Passband and Stopband Frequencies
OmegaP = (2/T)*tan(wp/2);
OmegaS = (2/T)*tan(ws/2);
[n,Omegac] = buttord(OmegaP,OmegaS,Rp,Rs,'s');
disp('The order of the filter is n= ');
disp('n');
//For H(S) transfer functions
[hs,pols,zers,gain]=analpf(n,'butt',0,Omegac);
A=coeff(denom(hs));
B=coeff(numer(hs));
figure(1);
freqz(B,A,512,%pi);
title('n=6 Butterworth Analog LP Filter')
//For H(Z) Transfer Functions
z=poly(0,'z')
hz=horner(hs,((1-(z^-1)/(1+(z^-1))))
C=coeff(denom(hz));
D=coeff(numer(hz));
figure(2);
freqz(D,C,512,%pi);
//Simulating digital filter
t=1:200;
Input=sin(0.1*%pi.*t)+sin(0.5*%pi.*t);
sl=tf2ss(hz);//Transfer functions to syslin representation
y=flts(Input,sl);//Filter the signal
figure(3)
subplot(211)
plot(t,Input);
xtitle('The Signal Before Using Digital Filter','t','y');
subplot(212)
plot(t,y);
xtitle('The Signal After Using Digital Filter','t','y');
===========================================================
You supposed get an output which are like this...
The testing of the digital Filter Signals
That's all , folks and wish you all a happy holiday !
UPDATES:
I had seen my coursemate coding works with a much more superior codes ( Means that they can design their digital butterworth filter without using the special SCILAB toolboxes provided by our lecturer ) Refer to my previous articles ~
Below is the their functions name and how it is used (According to them)
buttordc(): Function to calculate order of lter and its cut-o frequency
buttord(): Function to calculate order of lter
butterc(): Function to design analog Butterworth filter
butterd(): Function to design digital Butterworth lter using Bilinear Z - Transformation. ( BZT )
BTW, Tell you one most important thing~
I love Digital Signal Processing subject ! Wohoo !
1 comment:
And what about adding some more images? I don’t want to offend anyone, blog is really great. Just according to the scientists visitors acquire info much more efficient if they see certain useful pictures.
Whitney Nixon
mobile phone jamming
Post a Comment