Professional Documents
Culture Documents
DEPARTMENT OF ECE
DSP LAB
, -0.707092,-0.999969,-0.707092};
double spectrum[8];
// store data in bit reversal order
XR[0]=x[0];
XR[1]=x[4];
XR[2]=x[2];
XR[3]=x[6];
XR[4]=x[1];
XR[5]=x[5];
XR[6]=x[3];
XR[7]=x[7];
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
// clrscr( );
// FIRST STAGE OF BUTTERFLY
butterfly(&XR[0],&XI[0],&XR[1],&XI[1],&WNR[0],&WNI[0]);
butterfly(&XR[2],&XI[2],&XR[3],&XI[3],&WNR[0],&WNI[0]);
butterfly(&XR[4],&XI[4],&XR[5],&XI[5],&WNR[0],&WNI[0]);
butterfly(&XR[6],&XI[6],&XR[7],&XI[7],&WNR[0],&WNI[0]);
// SECOND STAGE OF BUTTERFLY
butterfly(&XR[0],&XI[0],&XR[2],&XI[2],&WNR[0],&WNI[0]);
butterfly(&XR[1],&XI[1],&XR[3],&XI[3],&WNR[2],&WNI[2]);
butterfly(&XR[4],&XI[4],&XR[6],&XI[6],&WNR[0],&WNI[0]);
butterfly(&XR[5],&XI[5],&XR[7],&XI[7],&WNR[2],&WNI[2]);
// THIRD STAGE OF BUTTERFLY
butterfly(&XR[0],&XI[0],&XR[4],&XI[4],&WNR[0],&WNI[0]);
butterfly(&XR[1],&XI[1],&XR[5],&XI[5],&WNR[1],&WNI[1]);
butterfly(&XR[2],&XI[2],&XR[6],&XI[6],&WNR[2],&WNI[2]);
butterfly(&XR[3],&XI[3],&XR[7],&XI[7],&WNR[3],&WNI[3]);
for(i=0;i<8;i++)
{
XR[i]*=64.0;
XI[i]*=64.0;
}
for(i=0;i<8;i++)
{
printf("\n FFT XR[%d] = %lf XI[%d]= %lf",i,XR[i],i,XI[i]);
}
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
return(0);
}
void butterfly(double *ar,double *ai,double *br,double *bi,double *wr,double *wi)
{
double tr,ti;
*ar/=4.0;
*ai/=4.0;
tr=*ar*2;
ti=*ai*2;
*br/=4.0;
*bi/=4.0;
*ar+=*br * *wr - *bi * *wi;
*ai+=*br * *wi + *bi * *wr;
*br= tr - *ar;
*bi= ti - *ai;
}
OUTPUT:
XR[0]=19.9999070; XI[0]=0.000000;
XR[1]=-5.828134;
XI[1]=-2.414237;
XR[2]=0.000813;
XI[2]=-0.000093;
XR[3]=-0.171618;
XI[3]=-0.414175;
XR[4]=0.000248;
XI[4]=0.000000;
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
OUTPUT:
enter the pass band cutoff frequency1500
enter the stop band cutt off frequency3000
enter pass band ripple in db10
enter stop band ripple in db40
enter the samling frequency7000
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
OUTPUT:
enter the pass band edge frequency200
enter the stop band edge frequency500
enter the sampling frequency1200
enter the pass band riples10
enter the stop band ripples100
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
OUTPUT:
enter the pass band edge frequency200
enter the stop band edge frequency500
enter the sampling frequency1200
enter the pass band ripple10
enter the stop band ripple100
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
PROGRAM:
clc;
close all;
clear all;
fp=input('enter the pass band edge frequency');
fs=input('enter the stop band edge frequency');
f=input('enter the sampling frequency');
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
wp=2*fp/f;
ws=2*fs/f;
[n,wn]=cheb2ord(wp,ws,rp,rs);
[b,a]=cheby2(n,rp,wn);
freqz(b,a);
OUTPUT:
enter the pass band edge frequency200
enter the stop band edge frequency500
enter the sampling frequency1200
enter the pass band ripple10
enter the stop band ripple100
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
PROGRAM:
clc;
close all;
clear all;
fc=input('enter the cutoff frequency');
fs=input('enter the sampling frequency');
N=input('enter the order of the filter');
if(rem(N,2)==0)
N=N+1;
end
wn=2*fc/fs;
wr=boxcar(N+1);
b=fir1(N,wn,wr);
freqz(b,1);
OUTPUT:
enter the cutoff frequency300
enter the sampling frequency1000
enter the order of the filter20
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
PROGRAM:
clc;
close all;
clear all;
fc=input('enter the cutoff frequency');
fs=input('enter the sampling frequency');
N=input('enter the order of the filter');
if(rem(N,2)==0)
N=N+1;
end
wn=2*fc/fs;
wr=triang(N+1);
b=fir1(N,wn,wr);
freqz(b,1);
OUTPUT:
enter the cutoff frequency300
enter the sampling frequency1000
enter the order of the filter20
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
PROGRAM:
clc;
close all;
clear all;
fc=input('enter the cutoff frequency');
fs=input('enter the sampling frequency');
N=input('enter the order of the filter');
B=15;
if(rem(N,2)==0)
N=N+1;
end
wn=2*fc/fs;
wr=kaiser(N+1,B);
b=fir1(N,wn,wr);
freqz(b,1);
OUTPUT:
enter the cutoff frequency300
enter the sampling frequency1000
enter the order of the filter20
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
PROGRAM:
clc;
close all;
clear all;
fc=input('enter the cutoff frequency');
fs=input('enter the sampling frequency');
N=input('enter the order of the filter');
if(rem(N,2)==0)
N=N+1;
end
wn=2*fc/fs;
wr=hamming(N+1);
b=fir1(N,wn,wr);
freqz(b,1);
OUTPUT:
enter the cutoff frequency300
enter the sampling frequency1000
enter the order of the filter20
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
13311A0444
DSP LAB
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
OUTPUT:
enter the cutoff frequency300
enter the sampling frequency1000
enter the order of the filter20
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
OUTPUT:
enter the pass band edge frequency200
enter the stop band edge frequency500
enter the sampling frequency1200
enter the pass band riples3
enter the stop band ripples100
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
DSP LAB
GRAPH:
13311A0444
2015-16
SNIST
DEPARTMENT OF ECE
13311A0444
DSP LAB
2015-16