RAJEEV GANDHI MEMORIAL COLLEGE OF ENGG AND TECH, NANDYAL M.

Tech (Digital Systems Computer Electronics)-II SEM SIGNAL PROCESSING LABORATORY LIST OF EXPERIMENTS: 1. Program to generate and plot various basis and trigonometric sequences 2. Program to find the convolution of given sequence with and without using buil tin functions and to plot the convolved sequence 3. Program to find the correlation of given sequences with and without using built-in functions and to plot the correlated sequence 4. Program to simulate the given system and to plot its frequency response and verify its stability described either by differential equations or by system fuction 5. Program to verify the properties(symmetry properties) of Fourier Transform 6. Program to verify Multirate Processing concepts of given signal (decimation/ interpolation) 7. Program to design the following I I R filter (using BW & CB approximation) i. LPF ii. HPF iii. BPF iv. BSF For the given specifications and plot its frequency response 8. Program to design various FIR filters using a) Rectangular window b) Hamming window c) Hanning window d) Blackman window e) Kaiser window For the given specifications and plot its frequency response 9. Program to design MR filters using Fourier series method 10. Program to find the power spectral density of given signal and to plot .

1.a. Addition of two sine waves N=21; n=0:1:N-1; x=sin(.1*pi*n)+sin(.2*pi*n); stem(n,x); xlabel('n'); ylabel('x'); title('addition of two sine wave sequences'); 1.b.Program for the generation of circle theta=linspace(0,2*pi,100); x=cos(theta); y=sin(theta); subplot(2,3,2); plot(x,y,'go');axis('equal'); xlabel('x(n)');ylabel('y(n)'); title('circle'); OUTPUT OF CIRCLE:

1.c.Program for the generation of impulse signal t=-2:1:2; y=[zeros(1,2) ones(1,1) zeros(1,2)]; subplot(2,3,1);stem(t,y);ylabel ('---------ï €Amplitude '); xlabel('-------ï € normalised frequency '); Output of impulse signal

1.d.Program for the generation of ramp signal n1=input('enter the length of ramp sequence'); t=0:n1; y=t; subplot(2,3,3);stem(t,t);ylabel('----ï €Amplitude'); xlabel('-ï €normalised frequency'); 1.e.Program for the generation of step signal N=input('enter the length of the sequence'); x=ones(1,N); n=0:1:N-1; subplot(2,2,1); stem(n,x);ylabel('Amplitude-->'); xlabel('-------> normalised frequency'); RESULT: input sequence:21

1.f.Program for the generation of sine waveform t=0:.01:pi; y=sin(2*pi*t); subplot(2,1,1);stem (t,y);ylabel('-----ï €Amplitude '); xlabel('----ï € normalised frequency '); Output of sine waveform

1.g.Program for the generation of exponential signal n2=input('enter the length of exponential sequence'); t=0:n2; a=input('enter the a value'); y=exp(a*t); subplot(2,2,4);stem(t,y);ylabel('Amplitude-->'); xlabel('------ï € uency'); RESULT: enter the length of exponential sequence5

normalised freq

enter the a value2

2.a.Convolution x=input('enter the 1st sequence'); h=input('enter the 2nd sequence'); y=conv2(x,h); subplot(3,1,1); stem(x); ylabel('amplitude'); xlabel('(a)n'); subplot(3,1,2); stem(h); ylabel('amplitude'); xlabel('(b)n'); subplot(3,1,3); stem(y); ylabel('amplitude'); xlabel('(c)n'); disp(y) Result: enter the 1st sequence[3 4 5 6] enter the 2nd sequence[3 4 5 6] 9 24 46 76 73 2.b.CIRCULAR CONVOLUTION x1=input('enter the seq1') x2=input('enter the seq2') l1=length(x1) l2=length(x2) n1=0:1:l1-1 subplot(3,1,1) stem(n1,x1) xlabel('time index') ylabel('amplitude') title('first sequence') n2=0:1:12-1 subplot(3,1,2) %stem(n2,x2) xlabel('time index') ylabel('amplitude') title('second sequence') N=max(l1,l2) y=conv2(x1,x2,N) N=max(l1,l2) n3=0:1:N-1 subplot(3,1,3) stem(n3,y) xlabel('time index') ylabel('amplitude') title('circular convolution') CIRCULAR CONVOLUTION FUNCTION FILE

60

36

function[y]=conv2(x1,x2,N) l1=length(x1) l2=length(x2) N=max(l1,l2) if(N<max(l1,l2)) error('N must be >=max(l1,l2)') end x1=[x1,zeros(1,N-l1)] x2=[x2,zeros(1,N-l2)] %circular shift of sequence 2 m=[0:1:N-1] M=mod(-m,N) x2=x2(M+1) H=zeros(N,N) for n=1:1:N m=n-1 p=0:1:N-1 q=mod(p-m,N) xm=x2(q+1) H(n,:)=xm end %matrix convolution y=x1*H' OUTPUT RESULT enter the seq1[1 2 2 1] x1 = 1 2 2 1

enter the seq2[1 2 2 1] x2 = 1 l1 = 4 l2 = 4 n1 = 0 n2 = Columns 1 through 10 0 1 2 3 4 5 6 7 8 9 1 2 3 2 2 1

Columns 11 through 12 10 11

N = 4 y = 4 8 8 4 N = 4 n3 = 0 1 2 3 8 16 16 8 8 16 16 8 4 8 8 4

3.CROSS CORRELATION x=input('enter the 1st sequence'); h=input('enter the 2nd sequence'); y=xcorr(x,h); subplot(3,1,1); stem(x); ylabel('amplitude'); xlabel('(a)n'); subplot(3,1,2); stem(h); ylabel('amplitude'); xlabel('(b)n'); subplot(3,1,3); stem(fliplr(y)); ylabel('amplitude'); xlabel('(c)n'); disp('The resultant is');y Result: enter the 1st sequence[3 4 5 6] enter the 2nd sequence[3 4 5 6] The resultant is

4.Frequency response of a given system b=[1 , .9]; a=[1 ,.4]; w=0:.01:pi; [h]=freqz(b,a,w); subplot(2,1,1); plot(w/pi,abs(h));xlabel('freq');ylabel('mag'); subplot(2,1,2); plot(w/pi,angle(h)); xlabel('freq');ylabel('phase');

5.a.FFT x=input('enter the sequence'); n=input('enter the length of fft'); y=fft(x,n); stem(y);axis([-5 30 -10 10]);ylabel('imaginery axis-->'); xlabel('real axis-->'); Result: enter the sequence[2 3 4 5 6] enter the length of fft8

5.b. Program for computing discrete fourier transform (Stable) clear all; close all; b=input('enter the denominator coeffcients of the filter'); k=poly2rc(b); knew=fliplr(k); s=all(abs(knew),1); if(s==1) disp(' "stable system" '); else disp (' "Nonstable system" '); end RESULT enter the denominator coeffcients of the filter[1 -1 5] "stable system" 6.a. PROGRAM FOR DECIMATE FUNCTION t=0:0.03:2; x=cos(4*pi*t); y=decimate(x,2);

t1=decimate(t,2); subplot(2,1,1); stem(t,x,'fill'); title('undecimated plot'); subplot(2,1,2); stem(t1,y,'fill'); title('Decimated plot'); RESULT:

6.b. PROGRAM FOR INTERPOLE FUNCTION t=0:0.03:2; x=cos(4*pi*t); y=interp(x,2); t1=interp(t,2); subplot(2,1,1); stem(t,x,'fill'); title('actual plot'); subplot(2,1,2); stem(t1,y,'fill'); title('interped plot'); RESULT

7. I I R FILTER (USING BW &CB) i. LPF ii. HPF iii. BPF iv. BSF i. LOW PASS FILTER (BW): rp=input ('enter the passband ripple'); rs =input ('enter the stopband ripple'); wp = input('enter the passbond frequency'); ws = input('enter the stopbond frequency'); fs = input('enter the sampling frequency'); w1 = 2 * wp/fs; w2 = 2 * ws / fs ; [n, wn] = buttord(w1,w2,rp,rs,'s'); [z,p,k] = butter(n,wn); [b,a] =zp2tf(z,p,k); [b,a] = butter (n,wn,'s'); w = 0:.01:pi; [h,om] = freqs(b,a,w);

m= 20*log10(abs(h)); an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('Gain in db--->');xlabel('(a) Normalised frequency--->'); subplot(2,1,2);plot(om/pi,an); xlabel ('(b) Normalised frequency-->'); ylabel ('phase in radians --->'); RESULT: enter the enter the enter the enter the enter the passband stopband passbond stopbond sampling ripple0.15 ripple60 frequency1500 frequency3000 frequency7000

ii. HIGH PASS FILTER (BW): rp=input ('enter the passband ripple'); rs =input ('enter the stopband ripple'); wp = input('enter the passbond frequency'); ws = input('enter the stopbond frequency'); fs = input('enter the sampling frequency'); w1 = 2 * wp/fs; w2 = 2 * ws / fs ; [n, wn] = buttord(w1,w2,rp,rs,'s'); [b,a] = butter (n,wn,'high','s'); w = 0:.01:pi; [h,om] = freqs(b,a,w); m= 20*log10(abs(h)); an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('Gain in db--->');xlabel('(a) Normalised frequency (hpf)--->'); subplot(2,1,2);plot(om/pi,an); xlabel ('(b) Normalised frequency(hpf)-->'); ylabel ('phase in radians --->'); RESULT enter the enter the enter the enter the enter the

passband stopband passbond stopbond sampling

ripple0.2 ripple40 frequency2000 frequency3500 frequency8000

iii. BANDPASS FILTER(BW): rp=input ('enter the passband ripple'); rs =input ('enter the stopband ripple'); wp = input('enter the passbond frequency'); ws = input('enter the stopbond frequency'); fs = input('enter the sampling frequency'); w1 = 2 * wp/fs; w2 = 2 * ws / fs ; [n] = buttord(w1,w2,rp,rs,'s'); wn=[w1 w2]; [b,a] = butter (n,wn,'bandpass','s'); w = 0:.01:pi;

[h,om] = freqs(b,a,w); m= 20*log10(abs(h)); an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('Gain in db--->');xlabel('(a) Normalised frequency (bpf)--->'); subplot(2,1,2);plot(om/pi,an); xlabel ('(b) Normalised frequency(bpf)-->'); ylabel ('phase in radians --->'); RESULT enter the enter the enter the enter the enter the

passband stopband passbond stopbond sampling

ripple0.36 ripple36 frequency1500 frequency2000 frequency6000

iv. BANDSTOP FILTER(BW): rp=input ('enter the passband ripple'); rs =input ('enter the stopband ripple'); wp = input('enter the passbond frequency'); ws = input('enter the stopbond frequency'); fs = input('enter the sampling frequency'); w1 = 2 * wp/fs; w2 = 2 * ws / fs ; [n] = buttord(w1,w2,rp,rs,'s'); wn=[w1 w2]; [b,a] = butter(n,wn,'stop','s'); w = 0:.01:pi; [h,om] = freqs(b,a,w); m= 20*log10(abs(h)); an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('Gain in db--->');xlabel('(a) Normalised frequency (bs)--->'); subplot(2,1,2);plot(om/pi,an); xlabel ('(b) Normalised frequency(bs)-->'); ylabel ('phase in radians --->'); RESULT: enter the enter the enter the enter the enter the passband stopband passbond stopbond sampling ripple0.28 ripple28 frequency1000 frequency1400 frequency5000

i. LOW PASS FILTER (CB): rp=input ('enter the passband ripple..'); rs =input ('enter the stopband ripple..'); wp = input('enter the passbond frequency..'); ws = input('enter the stopbond frequency..'); fs = input('enter the sampling frequency..'); w1 = 2 * wp/fs; w2 = 2 * ws / fs ; [n, wn] = cheb1ord(w1,w2,rp,rs,'s'); [b,a] = cheby1(n,rp,wn,'s');

w = 0:.01:pi; [h,om] = freqs(b,a,w); m= 20*log10(abs(h)); an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('Gain in db--->');xlabel('(a) Normalised frequency--->'); subplot(2,1,2);plot(om/pi,an); xlabel ('(b) Normalised frequency-->'); ylabel ('phase in radians --->'); RESULT: enter the enter the enter the enter the enter the passband stopband passbond stopbond sampling rippleâ ¦0.23 rippleâ ¦.47 frequencyâ ¦1300 frequencyâ ¦1550 frequencyâ ¦7800

ii. HIGH PASS FILTER(CB): rp=input ('enter the passband ripple..'); rs =input ('enter the stopband ripple..'); wp = input('enter the passbond frequency..'); ws = input('enter the stopbond frequency..'); fs = input('enter the sampling frequency..'); w1 = 2 * wp/fs; w2 = 2 * ws / fs ; [n, wn] = cheb1ord(w1,w2,rp,rs,'s'); [b,a] = cheby1(n,rp,wn,'high','s'); w = 0:.01:pi; [h,om] = freqs(b,a,w); m= 20*log10(abs(h)); an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('Gain in db--->');xlabel('(a) Normalised frequency--->'); subplot(2,1,2);plot(om/pi,an); xlabel ('(b) Normalised frequency-->'); ylabel ('phase in radians --->'); RESULT enter the passband ripple...29 enter the stopband ripple..29 enter the passbond frequency..900 enter the stopbond frequency..1300 enter the sampling frequency..7500

iii. BANDPASS FILTER(CB): rp=input ('enter the passband ripple..'); rs =input ('enter the stopband ripple..'); wp = input('enter the passbond frequency..'); ws = input('enter the stopbond frequency..');

fs = input('enter the sampling frequency..'); w1 = 2 * wp/fs; w2 = 2 * ws / fs ; [n] = cheb1ord(w1,w2,rp,rs,'s'); wn=[w1 w2]; [b,a]= cheby1(n,rp,wn,'bandpass','s'); w = 0:.01:pi; [h,om] = freqs(b,a,w); m= 20*log10(abs(h)); an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('Gain in db--->');xlabel('(a) Normalised frequency--->'); subplot(2,1,2);plot(om/pi,an); xlabel ('(b) Normalised frequency-->'); ylabel ('phase in radians --->'); RESULT enter the passband ripple.. 0.3 enter the stopband ripple.. 40 enter the passbond frequency.. 1400 enter the stopbond frequency.. 2000 enter the sampling frequency.. 5000

iv. BANDSTOP FILTER(CB): rp=input ('enter the passband ripple..'); rs =input ('enter the stopband ripple..'); wp = input('enter the passbond frequency..'); ws = input('enter the stopbond frequency..'); fs = input('enter the sampling frequency..'); w1 = 2 * wp/fs; w2 = 2 * ws / fs ; [n] = cheb1ord(w1,w2,rp,rs,'s'); wn=[w1 w2]; [b,a]= cheby1(n,rp,wn,'stop','s'); w = 0:.01:pi; [h,om] = freqs(b,a,w); m= 20*log10(abs(h)); an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('Gain in db--->');xlabel('(a) Normalised frequency--->'); subplot(2,1,2);plot(om/pi,an); xlabel ('(b) Normalised frequency-->'); ylabel ('phase in radians --->'); RESULT enter enter enter enter enter the the the the the passband stopband passbond stopbond sampling ripple.. 0.15 ripple.. 30 frequency.. 2000 frequency.. 2400 frequency.. 7000

8.FIR FILTERS USING i. Rectangular Window ii. Hamming Window

iii. Hanning window iv. Blackman Window v. Kaiser Window I. FIR FILTERS LPF, HPF, BPF, BSF USING RECTANGULAR WINDOW rp=input ('enter the passband ripple..'); rs =input ('enter the stopband ripple..'); fp = input('enter the passbond frequency..'); fs = input('enter the stopbond frequency..'); f = input('enter the sampling frequency..'); wp=2*fp/f; ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n; n=n-1; end y=boxcar(n1); %lowpass filter b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); Ylabel('gain in db--->'); Xlabel('(a) normalised freq--->'); %high pass filter b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); Ylabel('gain in db---->'); Xlabel('(b)normalised freq ------>'); %band pass filter wn=[wp,ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); Ylabel('gain in db ----->'); Xlabel('(c)normalised freq ---->'); %bandstop filter b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); Ylabel('gain in db------->'); Xlabel('(d) normalised freq------>'); RESULT: enter the passband ripple..0.05 enter the stopband ripple.. 0.04 enter the passbond frequency.. 1500

enter the stopbond frequency.. 2000 enter the sampling frequency.. 9000

ii.FIR FILTERS LPF,HPF,BPF,BSF USING HAMMING WINDOW rp=input('enter the pass band ripple'); rs=input('enter the stop band ripple'); fp=input('enter the pass freq'); fs=input('enter the stop freq'); f=input('enter the sampling freq'); wp=2*fp/f;ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n;n=n-1; end y=hamming(n1); %LOW PASSS FILTER b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(a)normalised frequency------>'); %HIGH PASS FILTER b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2);plot(o/pi,m);grid ylabel('gain in db---->'); xlabel('(b)normalised frequency------>'); %BAND PASS FILTER wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h));

subplot(2,2,3);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(c)normalised frequency------>'); %BAND STOP FILTER b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); ylabel('gain in db---->'); xlabel('(d) normalised frequency------>');

RESULT enter the enter the enter the enter the enter the

pass band ripple0.02 stop band ripple0.01 pass freq1200 stop freq1700 sampling freq9000

iii.FIR FILTERS LPF,HPF,BPF,BSF USING HANNING WINDOW rp=input('enter the pass band ripple'); rs=input('enter the stop band ripple'); fp=input('enter the pass freq'); fs=input('enter the stop freq'); f=input('enter the sampling freq'); wp=2*fp/f;ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n;n=n-1; end y=hanning(n1); %LOW PASSS FILTER b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(a)normalised frequency------>'); %HIGH PASS FILTER b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(b)normalised frequency------>');

%BAND PASS FILTER wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(c)normalised frequency------>'); %BAND STOP FILTER b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); ylabel('gain in db---->'); xlabel('(d) normalised frequency------>'); RESULT enter the pass band ripple0.03 enter the stop band ripple0.01 enter the pass freq1400 enter the stop freq2000 enter the sampling freq8000

iv.FIR FILTERS LPF,HPF,BPF,BSF USING BLACKMAN WINDOW rp=input('enter the pass band ripple'); rs=input('enter the stop band ripple'); fp=input('enter the pass freq'); fs=input('enter the stop freq'); f=input('enter the sampling freq'); wp=2*fp/f;ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n;n=n-1; end y=blackman(n1); %LOW PASSS FILTER b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(a)normalised frequency------>'); %HIGH PASS FILTER b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(b)normalised frequency------>');

%BAND PASS FILTER wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(c)normalised frequency------>'); %BAND STOP FILTER b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); ylabel('gain in db---->'); xlabel('(d) normalised frequency------>'); RESULT enter the enter the enter the enter the pass band ripple0.03 stop band ripple0.01 pass freq2000 enter the stop freq2500 sampling freq7000

V.FIR FILTERS LPF, HPF, BPF, BSF USING KAISER WINDOW rp=input('enter the pass band ripple'); rs=input('enter the stop band ripple'); fp=input('enter the pass freq'); fs=input('enter the stop freq'); f=input('enter the sampling freq'); beta=input('enter the beta value'); wp=2*fp/f;ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n; n=n-1; end y=kaiser(n1,beta); %LOW PASSS FILTER b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(a)normalised frequency------>'); %HIGH PASS FILTER b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(b)normalised frequency------>');

%BAND PASS FILTER wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3);plot(o/pi,m); ylabel('gain in db---->'); xlabel('(c)normalised frequency------>'); %BAND STOP FILTER b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); ylabel('gain in db---->'); xlabel('(d) normalised frequency------>'); RESULT enter the enter the enter the enter the enter the enter the pass band ripple 0.02 stop band ripple 0.01 pass freq 1000 stop freq 1500 sampling freq 10000 beta value 5.8

9.PROGRAM TO DESIGN MR FILTERS USING FS METHOD fs=20; f=[2,4]; a=[1 0]; Rp=0.1; Rs=40; %calculate allowable deviation of ripple dp=1-10^(-Rp/20); ds=10^(-Rs/20); dev=[dp ds]; %calculate order of the filter [n,Wn,beta,ftype]=kaiserord(f,a,dev,fs); Result using FS method:--

10.Power spectrum estimate using MATLAB n=input('enter the length of the sequence') window=hamming(n); nfft=input('length of the FFT');

fs=input('sampling frequency'); n=0:1:n-1; %signal sum of two sinusoids and random noise x=cos(2*.1*pi*n/fs)+sin(2*.4*pi*n/fs)+0.01*randn(size(n)); subplot(2,1,1),plot(n,x) xlabel('n'),ylabel('x(n)') [pxx,f]=periodogram(x,window,nfft,fs) subplot(2,1,2) plot(f/fs,10*log10(pxx));grid xlabel('\omega/\pi'),ylabel('power spectrum') Result:-enter the length of the sequence4 n = 4 length of the FFT4 sampling frequency1000 pxx = 0.0024 0.0016 0.0000 f = 0 250.0000 500.0000

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.