Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DSP Manuals

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 48

SUM OF TWO SINUSOIDAL SIGNALS Experiment No: - 01 AIM: - To write a MATLAB program to find the sum of two sinusoidal

signals. PROCEDURE: PROGRAM:clc; Clear all; Close all; t=0:0.001:0.1; f1=50; x1=2*pi*f1*t; y1=sin(x1); figure; subplot (3 1 1); plot (t y1); title(!sin(x1!); f2=100; x2=2*pi*f2*t; y2=sin(x2); subplot(3 1 2); plot(t y2); title(!sin(x2)!); y=y1"y2; subplot(3 1 3); plot(t y); title(!sinx1=sinx2!)

Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

RESULTS:T !" t e MATLA# pro$r%m &or "!m o& t'o "in!"oi(%) "i$n%)" '%" per&orme( %n( t e o!tp!t '%" *eri&ie(+

P%$e No 1

OUTPUT:

P%$e No ,

ANALOG LOW PASS FILTER Experiment No: - 0,-%. AIM: - To write a MATLAB program to plot magnitude response of analog Low pass filter. PROCEDURE: PROGRAM:clc; close all; clear all; f=100:20:#000; f$=%00; &=lengt$(f); for i=1:&; '(i)=1(s)rt(1"(f(i)(f$)*2); 'ag(i)=20*log10('(i)); en+; figure; se'ilogx(f 'ag); title(!'agnitu+e response of analog of lo, pass filter!) xlabel(!fre)uency-----.!); ylabel(!'agnitu+e in +b!); gri+ on;

Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

RESULTS:T !" t e MATLA# pro$r%m &or %n%)o$ Lo' p%"" &i)ter '%" 'ritten %n( m%$nit!(e re"pon"e '%" p)otte(+

P%$e No /

OUTPUT:-

P%$e No 0

ANALOG 1IG1 PASS FILTER Experiment No: - 0,-2. AIM: - TO write a MATLAB program to plot magnitude response of analog #igh pass filter.. PROCEDURE: PROGRAM:clc; close all; clear all; f=100:20:#000; fl=/00; &=lengt$(f); for i=1:&; '(i)=1(s)rt(1"(fl(f(i))*2); 'ag(i)=20*log10('(i)); en+; figure; se'ilogx(f 'ag); title(!'agnitu+e response of analog of $ig$ pass filter!); xlabel(!fre)uency-----.!); ylabel(!'agnitu+e in +b!); gri+ on;

Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

RESULTS:T !" t e MATLA# pro$r%m &or %n%)o$ i$ p%"" &i)ter '%" 'ritten %n( m%$nit!(e re"pon"e '%" p)otte(+

P%$e No 3

OUTPUT:

P%$e No 4

FIR LP51P FILTER USING 6AISER WINDOWING TEC1NI7UES Experiment No: - 0/-%. AIM: - TO write a MATLAB program to design FIR L$"#$ using %aiser window techni&ues. PROCEDURE: PROGRAM:clc; close all; clear all; for'at long; rp=input(!enter t$e passban+ ripple!); rs=input(!enter t$e stopban+ ripple!); fp=input(!enter t$e passban+ fre)uency!); fs=input(!enter t$e stopban+ fre)uency!); f=input(!enter t$e sa'pling fre)uency!); beta=input(!enter t$e beta 0alue!); ,p=2*(fp(f); ,s=2*(fs(f); nu'=-20*log10(s)rt(rp*rs))-13; +e'=1/.1*(fs-fp)(f; n=ceil(nu'(+e'); n1=n"1; if(re'(n 2)2=0) n1=n; n=n-1; en+; y=&aiser(n1 beta); 34o,pass filter b=fir1(n ,p y); 5$ o6=fre)7(b 1 251); '=20*log10(abs($)); subplot(2 1 1); plot(o(pi '); ylabel(!gain in +b----.!); xlabel(!8or'alise+ fre)uency----.!); title(!9:; filter using <aiser ,in+o, of 4=9 ----!); gri+ on;

Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

P%$e No 8

3>ig$pass filter b=fir1(n ,p !$ig$! y); 5$ o6=fre)7(b 1 251); '=20*log10(abs($));subplot(2 1 2); plot(o(pi '); ylabel(!gain in +b----.!); xlabel(!8or'alise+ fre)uency----.!); title(!9:; filter using <aiser ,in+o, of >=9 ----!); gri+ on;

RESULTS:-

Thus the MATLAB program for !' L$"#$ using %aiser (indow Techni&ues was e)ecuted.

INPUT:enter the pass *and ripple +.+, enter the stop *and ripple +.+enter the pass *and fre&uency -+++ enter the stop *and fre&uency -.++ enter the sampling fre&uency -++++ enter the *eta value ../

OUTPUT: P%$e No 9

P%$e No :

FIR LP51P FILTER USING TRIANGULAR WINDOWING TEC1NI7UES Experiment No: - 0/-2. AIM: - TO write a MATLAB program to design !' L$"#$ using Triangular window Techni&ues. PROCEDURE: PROGRAM:
clc; close all; clear all; for'at long; rp=input(!enter t$e passban+ ripple!); rs=input(!enter t$e stopban+ ripple!); fp=input(!enter t$e passban+ fre)uency!); fs=input(!enter t$e stopban+ fre)uency!); f=input(!enter t$e sa'pling fre)uency!); ,p=2*(fp(f); ,s=2*(fs(f); nu'=-20*log10(s)rt(rp*rs))-13; +e'=1/.1*(fs-fp)(f; n=ceil(nu'(+e'); n1=n"1; if(re'(n 2)2=0) n1=n; n=n-1; en+; y=triang(n1); 34o,pass filter b=fir1(n ,p y); 5$ o6=fre)7(b 1 251); '=20*log10(abs($)); subplot(2 1 1); plot(o(pi '); ylabel(!gain in +b----.!); xlabel(!8or'alise+ fre)uency----.!); title(!9:; filter using ?riangular ,in+o, of 4=9 ----!); gri+ on;

Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

P%$e No 10

3>ig$pass filter b=fir1(n ,p !$ig$! y); 5$ o6=fre)7(b 1 251); '=20*log10(abs($)); subplot(2 1 2); plot(o(pi '); ylabel(!gain in +b----.!); xlabel(!8or'alise+ fre)uency----.!); title(!9:; filter using ?riangular ,in+o, of >=9 ----!); gri+ on ;

RESULTS:Thus the MATLAB program for !' L$"#$ using triangular window Techni&ues was e)ecuted. INPUT:enter the pass*and ripple enter the stop*and ripple enter the pass*and fre&uency enter the stop*and fre&uency enter the sampling fre&uency +.+0 +.+, -.++ ,+++ /+++

P%$e No 11

OUTPUT:

P%$e No 1,

FIR LP51P FILTER USING RECTANGULAR WINDOWING TEC1NI7UES Experiment No: - 0/-<. AIM: - TO write a MATLAB program to design !' L$"#$ using ectangular window Techni&ues. PROCEDURE: PROGRAM:
clc; close all; clear all; for'at long; rp=input(!enter t$e passban+ ripple!); rs=input(!enter t$e stopban+ ripple!); fp=input(!enter t$e passban+ fre)uency!); fs=input(!enter t$e stopban+ fre)uency!); f=input(!enter t$e sa'pling fre)uency!); ,p=2*(fp(f); ,s=2*(fs(f); nu'=-20*log10(s)rt(rp*rs))-13; +e'=1/.1*(fs-fp)(f; n=ceil(nu'(+e'); n1=n"1; if(re'(n 2)2=0) n1=n; n=n-1; en+; y=boxcar(n1); 34o,pass filter b=fir1(n ,p y); 5$ o6=fre)7(b 1 251); '=20*log10(abs($)); subplot(2 1 1); plot(o(pi '); ylabel(!gain in +b----.!); xlabel(!8or'alise+ fre)uency----.!); title(!9:; filter using ;ectangular ,in+o, of 4=9 ----!); gri+ on;

Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

P%$e No 1/

3>ig$pass filter b=fir1(n ,p !$ig$! y); 5$ o6=fre)7(b 1 251); '=20*log10(abs($)); subplot(2 1 2); plot(o(pi '); ylabel(!gain in +b----.!); xlabel(!8or'alise+ fre)uency----.!); title(!9:; filter using ;ectangular ,in+o, of >=9 ----!); title(!@agnitu+e response of $ig$ pass filter!); gri+ on;

RESULTS:Thus the MATLAB program for !' L$"#$ using rectangular window Techni&ues was e)ecuted. INPUT:enter the pass*and ripple +.+0 enter the stop*and ripple +.+. enter the pass*and fre&uency -.++ enter the stop*and fre&uency ,+++ enter the sampling fre&uency 1+++

P%$e No 10

OUTPUT:

P%$e No 13

LINEAR CON=OLUTION USING MATLA# Experiment No: - 00 AIM: - TO write a MATLAB program to compute linear convolution of two given Se&uences. PROCEDURE: PROGRAM:clc; clear all; close; +isp(!enter t$e lengt$ of t$e first se)uence '=!); '=input(!!); +isp(!enter t$e lengt$ of first se)uence x5'6=!); for i=1:' x(i)=input(!!); en+ +isp(!enter t$e lengt$ of t$e secon+ se)uence n=!); n=input(!!); +isp(!enter t$e lengt$ of secon+ se)uence $5n6=!); for A=1:n $(A)=input(!!); en+ y=con0(x $); figure; subplot(3 1 1); ste'(x); ylabel (!a'plitu+e----.!); xlabel(!n----.!); title(!x(n) Bs n!); subplot(3 1 2); ste'($); ylabel(!a'plitu+e----.!); xlabel(!n----.!); title(!$(n) Bs n!); subplot(3 1 3); ste'(y); ylabel(!a'plitu+e----.!); xlabel(!n----.!); title(!y(n) Bs n!); +isp(!linear con0olution of x5'6 an+ $5n6 is y!);

Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

P%$e No 14

INPUT:-Cnter t$e lengt$ of t$e first se)uence '= 1 Cnter t$e lengt$ of first se)uence x5'6= 1 2 3 / 5 1 Cnter t$e lengt$ of t$e secon+ se)uence n= 1 Cnter t$e lengt$ of secon+ se)uence $5n6= 1 2 3 / 5 1

OUTPUT:4inear con0olution of x5'6 an+ $5n6 is y= 1 / 10 20 35 51 D0 D1 D3 10 31

RESULTS :- T !" t e pro$r%m &or )ine%r <on*o)!tion i" 'ritten !"in$ MATLA# %n( *eri&ie(+

CIRCULAR CON=OLUTION USING MATLA# Experiment No: - 03 AIM: - TO write a MATLAB program to compute Circular convolution of two given Se&uences. PROCEDURE: Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

PROGRAM:RESULTS:T !" t e pro$r%m &or <ir<!)%r <on*o)!tion i" 'ritten !"in$ MATLA# %n( *eri&ie(+

INPUT:enter the -st se&uence2- , 3 0 . 4 5 enter the ,nd se&uence2- , 3 0 .5

P%$e No 19

OUTPUT:Circular convolution of )6m7 and h6n7 is y8 .1 4, .1 .+ 3. .+

P%$e No 1:

#UTTERWORT1 LOW PASS FILTER Experiment No: - 04-%. AIM: - TO write a MATLAB program to Amplitude response and response of Butter worth Low pass filter

PROCEDURE: PROGRAM:clc; close all; clear all; for'at long; rp=input(!enter t$e passban+ ripple!); rs=input(!enter t$e stopban+ ripple!); ,p=input(!enter t$e passban+ fre)uency!); ,s=input(!enter t$e stopban+ fre)uency!); fs=input(!enter t$e sa'pling fre)uency!); ,1=2*,p(fs; ,2=2*,s(fs; 5n ,n6=buttor+(,1 ,2 rp rs !s!); 57 p &6= butter(n ,n); 5b a6=butter(n ,n !s!); ,=0:0.01:pi; 5$ o'6=fre)s(b a ,); '=20*log10(abs($)); an=angle($); subplot(2 1 1); plot(o'(pi '); ylabel(!gain in +b---------.!); xlabel(!(a) nor'ali7e+ fre)------.!); subplot(2 1 2); plot(o'(pi an); ylabel(!p$ase in +b---------.!); xlabel(!(b) nor'ali7e+ fre)------.!);

Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

P%$e No ,0

INPUT:enter t$e passban+ ripple.15 enter t$e stopban+ ripple10 enter t$e passban+ fre)uency1500

enter t$e stopban+ fre)uency3000 enter t$e sa'pling fre)uencyD000 RESULTS:T !" t e Amp)it!(e re"pon"e %n( p %"e re"pon"e o& #!tter 'ort Lo' p%"" &i)ter '%" *eri&ie(+

OUTPUT:-

P%$e No ,1

#UTTERWORT1 1IG1 PASS FILTER Experiment No: - 04-2. AIM: - TO write a MATLAB program to Amplitude response and response of Butter worth high pass filter PROCEDURE: Open MATLAB Open new M-file Type the program Save in current directory Compile and un the program !or the output see command window" !igure window

PROGRAM:clc; close all; clear all; for'at long; rp=input(!enter t$e passban+ ripple!); rs=input(!enter t$e stopban+ ripple!); ,p=input(!enter t$e passban+ fre)uency!); ,s=input(!enter t$e stopban+ fre)uency!); fs=input(!enter t$e sa'pling fre)uency!); ,1=2*,p(fs; ,2=2*,s(fs; 5n ,n6=buttor+(,1 ,2 rp rs !s!); 57 p &6= butter(n ,n); 5b a6=butter(n ,n !$ig$! !s!); ,=0:0.01:pi; 5$ o'6=fre)s(b a ,); '=20*log10(abs($)); an=angle($); subplot(2 1 1); plot(o'(pi '); ylabel(!gain in +b---------.!); xlabel(!(a) nor'ali7e+ fre)------.!); subplot(2 1 2); plot(o'(pi an); ylabel(!p$ase in +b---------.!); xlabel(!(b) nor'ali7e+ fre)------.!);

P%$e No ,,

INPUT:Cnter t$e Cnter t$e Cnter t$e Cnter t$e Cnter t$e RESULTS:-

passban+ stopban+ passban+ stopban+ sa'pling

ripple.2 ripple/0 fre)uency2000 fre)uency3500 fre)uency#000 i$ p%"" &i)ter '%" *eri&ie(+

T !" t e Amp)it!(e re"pon"e %n( p %"e re"pon"e o& #!tter 'ort OUTPUT:

P%$e No ,/

LINER CON=OLUTION

Experiment No: - 08 AIM: - TO write a C- program to find linear convolution of given two se&uences Pro<e(!re to Wor> on Co(e Compo"er St!(io To create the 9ew $ro:ect $ro:ect; 9ew 6!ile 9ame. p:t< =g> ?ectors.p:t7 To create a Source file !ile ;9ew; Type the code 6Save @ give file name< =g> sum.c7. To Add Source files to $ro:ect $ro:ect; Add files to $ro:ect; sum.c To Add rts.li* file @ #ello.cmd> $ro:ect; Add files to $ro:ect; rts4A++.li* Li*rary files> rts4A++.li* 6$ath> c>"ti"c4+++"cgtools"li*" rts4A++.li*7 9ote> Select O*:ect@ Li*rary in 6B.o<B.l7 in Type of files $ro:ect; Add files to $ro:ect;hello.cmd CMC file- (hich is common for all non real time programs. 6$ath> c>"ti " tutorial"dsD4A-3"hello-"hello.cmd7 9ote> Select LinDer Command file 6B.cmd7 in Type of files Compi)e:To Compile> $ro:ect; Compile To e*uild> pro:ect ; re*uild< (hich will create the final .out e)ecuta*le file. 6=g.?ectors.out7. $rocedure to Lode and un program> Load the $rogram to CS%> !ile; Load program ;?ectors.out To =)ecute pro:ect> Ce*ug ; un P%$e No ,0

PROGRAM:EincludeFstdio.hG int m84H int n84H int i8+<:H int )2-.58I-<,<3<0<.<4<+<+<+<+<+<+JH int h2-.58I-<,<3<0<.<4<+<+<+<+<+<+JH int y2,+5H main67 I for6i8+HiFmKn--HiKK7 I y2i58+H for6:8+H:F8iH:KK7 y2i5K8)2:5Bh2i-:5H J for6i8+HiFmKn--HiKK7 printf6LMd "nL<y2i57H J

RESULTS:- T !" t e C- Pro$r%m &or Line%r <on*o)!tion '%" 'ritten %n( t e o!tp!t '%" *eri&ie( OUTPUT:0 -+ ,+ 3. .4 A+ A4 A3 4+ 34

P%$e No ,3

P%$e No ,4

P%$e No ,8

CIRCULAR CON=OLUTION Experiment No: - 09 AIM: - TO write a C- program to find Circular convolution of given two se&uences Pro<e(!re to Wor> on Co(e Compo"er St!(io To create the 9ew $ro:ect $ro:ect; 9ew 6!ile 9ame. p:t< =g> ?ectors.p:t7 To create a Source file !ile ;9ew; Type the code 6Save @ give file name< =g> sum.c7. To Add Source files to $ro:ect $ro:ect; Add files to $ro:ect; sum.c To Add rts.li* file @ #ello.cmd> $ro:ect; Add files to $ro:ect; rts4A++.li* Li*rary files> rts4A++.li* 6$ath> c>"ti"c4+++"cgtools"li*" rts4A++.li*7 9ote> Select O*:ect@ Li*rary in 6B.o<B.l7 in Type of files $ro:ect; Add files to $ro:ect;hello.cmd CMC file- (hich is common for all non real time programs. 6$ath> c>"ti " tutorial"dsD4A-3"hello-"hello.cmd7 9ote> Select LinDer Command file 6B.cmd7 in Type of files Compi)e:To Compile> $ro:ect; Compile To e*uild> pro:ect ; re*uild< (hich will create the final .out e)ecuta*le file. 6=g.?ectors.out7. $rocedure to Lode and un program> Load the $rogram to CS%> !ile; Load program ;?ectors.out To =)ecute pro:ect> Ce*ug ; un

PROGRAM:EincludeFstdio.hG int m<n<)23+5<h23+5<y23+5<i<:<temp23+5<D<),23+5<a23+5H void main67 I printf6Lenter the length of the -st se&uence"nL7H scanf6LMdL<@m7H printf6Lenter the length of the second se&uence"nL7H scanf6LMdL<@n7H printf6Lenter the -st se&uence"nL7H for6i8+HiFmHiKK7 scanf6LMdL<@)2i57H printf6Lenter the second se&uence"nL7H for6:8+H:FnH:KK7 scanf6LMdL<@h2:57H if6m-nN8+7 I if6mGn7 I for6i8nHiFmHiKK7 h2i58+H n8mH J for6i8mHiFnHiKK7 )2i58+H m8nH J y2+58+H a2+58h2+5H for6:8-H:FnH:KK7 a2:58h2n-:5H for6i8+HiFnHiKK7 y2+5K8)2i5Ba2i5H for6D8-HDFnHDKK7 I y2D58+H for6:8-H:FnH:KK7 ),2:58a2:--5H ),2+58a2n--5H for6i8+HiFnHiKK7 I a2i58),2i5H y2D5K8)2i5B),2i5H J J printf6Lthe circular convolution is"nL7H for6i8+HiFnHiKK7 printf6LMd"tL<y2i57H J

INPUT:enter the length of the -st se&uence . enter the length of the second se&uence . enter the -st se&uence , 3 0 . enter the second se&uence , 3 0 . OUTPUT:the circular convolution is 0. .+ .+ 0. 3.

RESULTS:- T !" t e C- Pro$r%m &or Cir<!)%r <on*o)!tion '%" 'ritten %n( t e o!tp!t '%" *eri&ie(

9 ? FFT Experiment No: - 0: AIM: - TO write a C- program to compute / O !!T of given se&uences using C'! O !!T algorithm Pro<e(!re to Wor> on Co(e Compo"er St!(io To create the 9ew $ro:ect $ro:ect; 9ew 6!ile 9ame. p:t< =g> ?ectors.p:t7 To create a Source file !ile ;9ew; Type the code 6Save @ give file name< =g> sum.c7. To Add Source files to $ro:ect $ro:ect; Add files to $ro:ect; sum.c To Add rts.li* file @ #ello.cmd> $ro:ect; Add files to $ro:ect; rts4A++.li* Li*rary files> rts4A++.li* 6$ath> c>"ti"c4+++"cgtools"li*" rts4A++.li*7 9ote> Select O*:ect@ Li*rary in 6B.o<B.l7 in Type of files $ro:ect; Add files to $ro:ect;hello.cmd CMC file- (hich is common for all non real time programs. 6$ath> c>"ti " tutorial"dsD4A-3"hello-"hello.cmd7 9ote> Select LinDer Command file 6B.cmd7 in Type of files Compi)e:To Compile> $ro:ect; Compile To e*uild> pro:ect ; re*uild< (hich will create the final .out e)ecuta*le file. 6=g.?ectors.out7. $rocedure to Lode and un program> Load the $rogram to CS%> !ile; Load program ;?ectors.out To =)ecute pro:ect> Ce*ug ; un

P%$e No // PROGRAM:-

EincludeFstdio.hG EincludeFmath.hG Edefine 9 / Edefine $' 3.-0-.1 typedef struct I float real<imagH J comple)H main67 I int iH comple) w295H comple) )2/58I+<+.+<-<+.+<,<+.+<3<+.+<0<+.+<.<+.+<4<+.+<A<+.+JH comple) temp-<temp,H int :<D<upperPleg<lowerPleg<legPdiff<inde)<stepH for6i8+HiF9HiKK7 I w2i5.real8cos66,B$'Bi7Q69B,.+77H w2i5.imag8-sin66,B$'Bi7Q69B,.+77H J legPdiff89Q,H step8,H for6i8+HiF3HiKK7 I inde)8+H for6:8+H:FlegPdiffH:KK7 I for6upperPleg8:HupperPlegF9HupperPlegK86,BlegPdiff77 I lowerPleg8upperPlegKlegPdiffH temp-.real86)2upperPleg57.realK6)2lowerPleg57.realH temp-.imag86)2upperPleg57.imagK6)2lowerPleg57.imagH temp,.real86)2upperPleg57.real-6)2lowerPleg57.realH temp,.imag86)2upperPleg57.imag-6)2lowerPleg57.imagH 6)2lowerPleg57.real8temp,.realB6w2inde)57.real-temp,.imagB6w2inde)57.imagH 6)2lowerPleg57.imag8temp,.realB6w2inde)57.imagKtemp,.imagB6w2inde)57.realH 6)2upperPleg57.real8temp-.realH 6)2upperPleg57.imag8temp-.imagH J inde)K8stepH J

P%$e No /0

legPdiff86legPdiff7Q,H step8stepB,H J :8+H for6i8-HiF69--7HiKK7 I D89Q,H while6DF8:7 I :8:-DH D8DQ,H J :8:KDH if6iF:7 I temp-.real86)2:57.realH temp-.imag86)2:57.imagH 6)2:57.real86)2i57.realH 6)2:57.imag86)2i57.imagH 6)2i57.real8temp-.realH 6)2i57.imag8temp-.imagH J J printf6Lthe fft of the given input se&uence is "nL7H for6i8+HiF/HiKK7 I printf6LMf Mf "nL<6)2i57.real<6)2i57.imag7H J J OUTPUT:the fft of the given input se&uence is> ,/.++++++ +.++++++ -0.++++-, 1.4.4/./ -0.+++++. 0.++++++ -0.++++-+ -.4.4/.-0.++++++ +.++++++ -3.11111/ --.4.4/./ -3.11111. -0.++++++ -3.1111/+ -1.4.4/.-

P%$e No /3

FFT 1-D Experiment No: - 10 AIM: - TO write a C- program to compute !!T of the given -- C signal and plot

A)$orit m:-. ,. 3. 0. .. Select no. of points for !!T Renerate a sine wave of fre&uency SfT. TaDe sampled data and apply !!T algorithm. Use Rraph option to view the input and output. epeat step -to 0 for different no. of points and fre&uencies.

PROGRAM:EincludeFstdio.hG EincludeFmath.hG Edefine 9 3, Edefine $' 3.-0-.1 typedef struct I float real<imagH J comple)H float io*uffer295H float y295H main67 I int iH comple) w295H comple) )295H comple) temp-<temp,H int :<D<upperPleg<lowerPleg<legPdiff<inde)<stepH for6i8+HiF9HiKK7 I io*uffer2i58sin66,B$'B,Bi7Q3,.+7H J for6i8+HiF9HiKK7 I P%$e No /4

)2i5.real8io*uffer2i5H )2i5.imag8+.+H J for6i8+HiF9HiKK7 I w2i5.real8cos66,B$'Bi7Q69B,.+77H w2i5.imag8-sin66,B$'Bi7Q69B,.+77H J legPdiff89Q,H step8,H for6i8+HiF.HiKK7 I inde)8+H for6:8+H:FlegPdiffH:KK7 I for6upperPleg8:HupperPlegF9HupperPlegK86,BlegPdiff77 I lowerPleg8upperPlegKlegPdiffH temp-.real86)2upperPleg57.realK6)2lowerPleg57.realH temp-.imag86)2upperPleg57.imagK6)2lowerPleg57.imagH temp,.real86)2upperPleg57.real-6)2lowerPleg57.realH temp,.imag86)2upperPleg57.imag-6)2lowerPleg57.imagH 6)2lowerPleg57.real8temp,.realB6w2inde)57.real-temp,.imagB6w2inde)57.imagH 6)2lowerPleg57.imag8temp,.realB6w2inde)57.imagKtemp,.imagB6w2inde)57.realH 6)2upperPleg57.real8temp-.realH 6)2upperPleg57.imag8temp-.imagH J inde)K8stepH J legPdiff86legPdiff7Q,H step8stepB,H J :8+H for6i8-HiF69--7HiKK7 I D89Q,H while6DF8:7 I :8:-DH D8DQ,H J P%$e No /8 :8:KDH

if6iF:7 I temp-.real86)2:57.realH temp-.imag86)2:57.imagH 6)2:57.real86)2i57.realH 6)2:57.imag86)2i57.imagH 6)2i57.real8temp-.realH 6)2i57.imag8temp-.imagH J J for6i8+HiF9HiKK7 I y2i58s&rt66)2i5.realB)2i5.real7K6)2i5.imagB)2i5.imag77H J for6i8+HiF9HiKK7 I printf6LMf"tL<y2i57H J return6+7H J OUTPUT:-

P%$e No /9

P%$e No /:

POWER DENSIT@ SPECTRUM Experiment No: - 11 AIM: - TO write a C- program to compute power density spectrum of given one O dimensional signal and plot.

A)$orit m:- Select no. of points for !!T , Renerate a sine wave of fre&uency SfT.6Sampling rate 8 9o. of points of !!T7 3 Compute the Auto Correlation of sine wave. 0 TaDe output of auto correlation< apply !!T algorithm. . Use Rraph option to the $CS. . 4. epeat step -to 0 for different no. of points and fre&uencies. PROGRAM:EincludeFstdio.hG EincludeFmath.hG Edefine 9 -4 Edefine $' 3.-0-.1 typedef struct I float real<imagH J comple)H comple) )295H float io*uffer295H float )-295<y295H int iH main67 I comple) w295H comple) temp-<temp,H float sum8+.+H int :<D<n<upperPleg<lowerPleg<legPdiff<inde)<stepH for6i8+HiF9HiKK7 I

P%$e No 00

io*uffer2i58sin66,B$'B,Bi7Q-..+7H J for6n8+HnF9HnKK7 I sum8+H for6D8+HDF9-nHDKK7 I sum8sumK6io*uffer2D5Bio*uffer2nKD57H J )-2n58sumH J for6i8+HiF9HiKK7 I )2i5.real8)-2i5H )2i5.imag8+.+H J for6i8+HiF9HiKK7 I w2i5.real8cos66,B$'Bi7Q69B,.+77H w2i5.imag8-sin66,B$'Bi7Q69B,.+77H J legPdiff89Q,H step8,H for6i8+HiF0HiKK7 I inde)8+H for6:8+H:FlegPdiffH:KK7 I for6upperPleg8:HupperPlegF9HupperPlegK86,BlegPdiff77 I lowerPleg8upperPlegKlegPdiffH temp-.real86)2upperPleg57.realK6)2lowerPleg57.realH temp-.imag86)2upperPleg57.imagK6)2lowerPleg57.imagH temp,.real86)2upperPleg57.real-6)2lowerPleg57.realH temp,.imag86)2upperPleg57.imag-6)2lowerPleg57.imagH 6)2lowerPleg57.real8temp,.realB6w2inde)57.real-temp,.imagB6w2inde)57.imagH 6)2lowerPleg57.imag8temp,.realB6w2inde)57.imagKtemp,.imagB6w2inde)57.realH 6)2upperPleg57.real8temp-.realH 6)2upperPleg57.imag8temp-.imagH J inde)K8stepH J

P%$e No 01 legPdiff86legPdiff7Q,H

step8stepB,H J :8+H for6i8-HiF69--7HiKK7 I D89Q,H while6DF8:7 I :8:-DH D8DQ,H J :8:KDH if6iF:7 I temp-.real86)2:57.realH temp-.imag86)2:57.imagH 6)2:57.real86)2i57.realH 6)2:57.imag86)2i57.imagH 6)2i57.real8temp-.realH 6)2i57.imag8temp-.imagH J J for6i8+HiF9HiKK7 I y2i58s&rt66)2i5.realB)2i5.real7K6)2i5.imagB)2i5.imag77H J for6i8+HiF9HiKK7 I printf6LMf"tL<y2i57H J return6+7H J

OUTPUT:P%$e No 0,

P%$e No 0/

P%$e No 00

P%$e No 03

P%$e No 04

You might also like