INPUT: Enter the N value6 Enter the length of ramp sequence10 Enter the length of exponential sequence5 Enter the a value4 OUTPUT: GENERATION OF FUNCTIONAL SEQUENCES; clc; clear all; close all; %program for the generation of unit impulse signal t=-2:1:2; y=[zeros(1,2),ones(1,1),zeros(1,2)]; subplot(2,2,1); stem(t,y); ylabel('amplitude--.'); xlabel('(a)n--.'); %program for the generation of unit step sequence [u(n)2u(n 2 N)] n=input('enter the N value'); t=0:1:n-1; y1=ones(1,n); subplot(2,2,2); stem(t,y1); ylabel('amplitude--.'); xlabel('(b)n--.'); %program for the generation of ramp sequence n1=input('enter the length of ramp sequence'); t=0:n1; subplot(2,2,3); stem(t,t); ylabel('amplitude--.'); xlabel('(c)n--.'); %program for the generation of exponential sequence n2=input('enter the length of exponential sequence'); t=0:n2; a=input('Enter the a value'); y2=exp(a*t); subplot(2,2,4); stem(t,y2); ylabel('amplitude--.'); xlabel('(d)n--.'); %program for the generation of continuous exponential sequences n3=input('enter the n value')' t=0:2:n3-1; a=input('enter the a value'); y3=exp(a*t); subplot(3,1,1); plot(t,y3); ylabel('amplitude--.'); xlabel('(a)n--.'); %program for the generation of sine sequence t=0:.01:pi; y=sin(2*pi*t); subplot(3,1,2); plot(t,y); ylabel('amplitude--.'); xlabel('(a)n--.'); %program for the generation of cosine sequence t=0:.01:pi; y=cos(2*pi*t); subplot(3,1,3); plot(t,y); ylabel('amplitude--.'); xlabel('(b)n--.'); INPUT: Enter the n value6 Enter the a value0.2 OUTPUT: OUTPUT:(RANDOM SEQUENCES) RANDOM SEQUENCES N=1024; R1=randn(1,N); R2=rand(1,N); figure(1); subplot(2,2,1); plot(R1); grid; title('normal[gaussion]distributed random signal'); xlabel('sample number'); ylabel('amplitude'); subplot(2,2,2); hist(R1); grid; title('histogram[pdf]of a normal random signal'); xlabel('sample number'); ylabel('total'); subplot(2,2,3); plot(R2); grid; title('uniformly distributed random signal'); xlabel('sample number'); ylabel('amplitude'); subplot(2,2,4); hist(R2); grid; title('histogram[pdf]of a uniformly random signal'); xlabel('sample number'); ylabel('Total'); RESULT INPUT: Enter the sequence[5 8 4] The resultant signal is20 72 105 72 20 OUTPUT: AUTO CORRELATION Clc; Clear all; close all; x=input('enter the sequence'); y=xcorr(x,x); figure; subplot(2,1,1); stem(x); ylabel('amplitude--.') xlabel('(a)n--.'); subplot(2,1,2); stem(fliplr(y)); ylabel('amplitude--.'); xlabel('(a)n--.'); disp('the resultant signal is'); fliplr(y INPUT: Enter the 1st sequence[5 8 4] Enter the 2nd sequence[2 5 4] The resultant signal is ans = 8 36 66 57 20 OUTPUT: CROSS CORRELATION clc; clear all; close all; x=input('enter the 1st sequence'); h=input('enter the 2nd sequence'); y=xcorr(x,h); figure; 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 signal is '); fliplr(y) x=input('enter the sequence'); y=xcorr(x,x); figure; subplot(2,1,1); stem(x); ylabel('amplitude--.'); xlabel('(a)n--.'); subplot(2,1,2); stem(fliplr(y)); ylabel('amplitude--.'); xlabel('(a)n--.'); disp('The resultant signal is'); fliplr(y), RESULT INPUT: enter the input sequence:[3 4 7] enter the impulse sequence:[2 6 7] the resultant signal is y =76 75 59 OUTPUT: CIRCULARCONVOLUTION clc; close all; clear all; g=input('enter the input sequence:'); h=input('enter the impulse sequence:'); N1=length(g); N2=length(h); N=max(N1,N2); N3=N1-N2; if(N3>=0); h=[h,zeros(1,N3)]; else g=[g,zeros(1,N3)]; end for n=1:N y(n)=0; for i=1:N j=n-i+1; if(j<=0) j=N+j; end y(n)=y(n)+(g(i)*h(j)); end end subplot(1,3,1); stem(g); xlabel('(g(n)...>'); ylabel('amplitude'); title('input sequence'); subplot(1,3,2); stem(h); xlabel('h(n)'); ylabel('amplitude'); title('impulse sequence'); subplot(1,3,3); stem(y); xlabel('y(n)'); ylabel('amplitude'); title('convolution sequence'); disp('the resultant signal is');y INPUT: enter the length of input sequence4 enter the length of impulse sequence4 enter input sequence[2 5 38] enter impulse sequence[7 5 2 9] enter the sequence of y y =14 45 50 99 91 43 72 OUTPUT LINEAR CONVOLUTION clc; close; clear all; n=input('enter the length of input sequence'); n1=input('enter the length of impulse sequence'); x=input('enter input sequence'); h=input('enter impulse sequence'); y=conv(x,h); subplot(1,3,1); stem(x); xlabel('n ----->'); ylabel('amp ----->'); title('input sequence'); subplot(1,3,2); stem(h); ylabel('amplitude ----->'); xlabel('n----->'); title ('impulse response'); subplot(1,3,3); stem(y); ylabel('amplitude----->'); xlabel('n------>'); title('linear convolution'); disp('enter the sequence of y');y RESULT INPUT: enter the pass band ripple0.04 enter the stopband ripple0.02 enter the passband freq1000 enter the stopband freq2000 enter the sampling freq8000 OUTPUT: FINITE IMPULSE RESPONSE RECTANGULAR WINDOW clc; clear all; close all; rp=input('enter the pass band ripple'); rs=input('enter the stopband ripple'); fp=input('enter the passbandfreq'); fs=input('enter the stopbandfreq'); 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=boxcar(n1); b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('LPF'); ylabel('gain in dB--.'); xlabel '(a)normalisedfreq--.'); 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); title('HPF'); ylabel('gain in dB--.'); xlabel('(b)normalisedfreq--.'); 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); title('BPF'); ylabel('gain in dB-->'); xlabel('(c)normalisedfreq-->'); wn=[wp,ws]; 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); title('BSF'); ylabel('gain in dB-->'); xlabel('(d)normalisedfreq-->'); INPUT: enter the pass band ripple0.04 enter the stopband ripple0.02 enter the passband freq1000 enter the stopband freq2000 enter the sampling freq8000 OUTPUT: TRIANGULAR WINDOW clc; clear all; close all; rp=input('enter the pass band ripple'); rs=input('enter the stopband ripple'); fp=input('enter the passbandfreq'); fs=input('enter the stopbandfreq'); 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=triang(n1); b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('LPF'); ylabel('gain in dB--.'); xlabel('(a)normalisedfreq--.'); 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); title('HPF'); ylabel('gain in dB--.'); xlabel('(b)normalisedfreq--.'); 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); title('BPF'); ylabel('gain in dB-->'); xlabel('(c)normalisedfreq-->'); wn=[wp,ws]; 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); title('BSF'); ylabel('gain in dB-->'); xlabel('(d)normalisedfreq-->'); INPUT: enter the pass band ripple0.04 enter the stopband ripple0.02 enter the passband freq1000 enter the stopband freq2000 enter the sampling freq8000 OUTPUT: HAMMING WINDOW clc; clear all; close all; rp=input('enter the pass band ripple'); rs=input('enter the stopband ripple'); fp=input('enter the passbandfreq'); fs=input('enter the stopbandfreq'); 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); b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('LPF'); ylabel('gain in dB--.'); xlabel('(a)normalisedfreq--.'); 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); title('HPF'); ylabel('gain in dB--.'); xlabel('(b)normalisedfreq--.'); 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); title('BPF'); ylabel('gain in dB-->'); xlabel('(c)normalisedfreq-->'); wn=[wp,ws]; 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); title('BSF'); ylabel('gain in dB->'); xlabel('(d)normalisedfreq-->'); INPUT: enter the pass band ripple0.04 enter the stopband ripple0.02 enter the passband freq1000 enter the stopband freq2000 enter the sampling freq8000 OUTPUT: HANNING WINDOW clc; clear all; close all; rp=input('enter the pass band ripple'); rs=input('enter the stopband ripple'); fp=input('enter the passbandfreq'); fs=input('enter the stopbandfreq'); 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); b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('LPF'); ylabel('gain in dB--.'); xlabel('(a)normalisedfreq--.'); 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); title('HPF'); ylabel('gain in dB--.'); xlabel('(b)normalisedfreq--.'); 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); title('BPF'); ylabel('gain in dB-->'); xlabel('(c)normalisedfreq-->'); wn=[wp,ws]; 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); title('BSF'); ylabel('gain in dB-->'); xlabel('(d)normalisedfreq-->'); INPUT: enter the pass band ripple0.04 enter the stopband ripple0.02 enter the passband freq1000 enter the stopband freq2000 enter the sampling freq8000 OUTPUT: BLACKMAN WINDOW clc; clear all; close all; rp=input('enter the pass band ripple'); rs=input('enter the stopband ripple'); fp=input('enter the passbandfreq'); fs=input('enter the stopbandfreq'); 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); b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('LPF'); ylabel('gain in dB--.'); xlabel('(a)normalisedfreq--.'); 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); title('HPF'); ylabel('gain in dB--.'); xlabel('(b)normalisedfreq--.'); 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); title('BPF'); ylabel('gain in dB-->'); xlabel('(c)normalisedfreq-->'); wn=[wp,ws]; 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); title('BSF'); ylabel('gain in dB-->'); xlabel('(d)normalisedfreq-->'); INPUT: enter the pass band ripple0.04 enter the stopband ripple0.02 enter the passbandfreq1000 enter the stopbandfreq2000 enter the sampling freq8000 OUTPUT: KAISER WINDOW clc; clear all; close all; rp=input('enter the pass band ripple'); rs=input('enter the stopband ripple'); fp=input('enter the passbandfreq'); fs=input('enter the stopbandfreq'); 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=kaiser(n1); b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('LPF'); ylabel('gain in dB--.'); xlabel('(a)normalisedfreq--.'); 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); title('HPF');ylabel('gain in dB--.'); xlabel('(b)normalisedfreq--.'); 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); title('BPF');ylabel('gain in dB-->'); xlabel('(c)normalisedfreq-->'); wn=[wp,ws]; 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); title('BSF'); ylabel('gain in dB-->'); xlabel('(d)normalisedfreq-->'); RESULT INPUT: enter the passband ripple0.6 enter the stop band ripple25 enter the passbandfreq1300 enter the stopbandfreq3000 enter the sampling freq8000 OUTPUT: INFINITE IMPULSE RESPONSE BUTTERWORTH FILTER clc; close all; clear all; rp=input('enter the passband ripple'); rs=input('enter the stop band ripple'); wp=input('enter the psaabandfreq'); ws=input('enter the stopbandfreq'); fs=input('enter the sampling freq'); w1=2*wp/fs; w2=2*ws/fs; [n,wn]=buttord(w1,w2,rp,rs); [b,a]=butter(n,wn); [h,w]=freqz(b,a,512); m=20*log10(abs(h)); an=angle(h); subplot(2,2,1); plot(w,abs(h)); ylabel('gain'); xlabel('normalized frequency'); title('LPF'); [b,a]=butter(n,wn,'high'); [h,w]=freqz(b,a,512); m=20*log10(abs(h)); an=angle(h); subplot(2,2,2); plot(w,abs(h)); ylabel('gain'); xlabel('normalized frequency'); title('HPF'); wn1=[w1 w2]; [b,a]=butter(n,wn1,'bandpass'); [h,w]=freqz(b,a,512); m=20*log10(abs(h)); an=angle(h); subplot(2,2,3); plot(w,abs(h)); ylabel('gain'); xlabel('normalized frequency'); title('BPF'); wn2=[w1 w2]; [b,a]=butter(n,wn2,'stop'); m=20*log10(abs(h)); an=angle(h); subplot(2,2,4); plot(w,abs(h)); ylabel('gain'); xlabel('normalized frequency'); title('BSF'); INPUT: enter the passband ripple.25 enter the stop band ripple40 enter the psaaband freq2500 enter the stopband freq2750 enter the sampling freq7000 OUTPUT: CHEBYSHEV -1 INFINITE IMPULSE RESPONSE FILTER clc; close all; clear all; format long rp=input('enter the passband ripple'); rs=input('enter the stop band ripple'); wp=input('enter the psaabandfreq'); ws=input('enter the stopbandfreq'); fs=input('enter the sampling freq'); w1=2*wp/fs; w2=2*ws/fs; [n,wn]=cheb1ord(w1,w2,rp,rs); [b,a]=cheby1(n,rp,wn); w=0:.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,2,1); plot(om/pi,m); ylabel('gain'); xlabel('a'); [b,a]=cheby1(n,rp,wn,'high'); w=0:.01/pi:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,2,2); plot(om/pi,m); ylabel('gain'); xlabel('a'); wn=[w1 w2]; [b,a]=cheby1(n,rp,wn,'bandpass'); w=0:0.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,2,3); plot(om/pi,m); ylabel('gain'); xlabel('c'); wn=[w1 w2]; [b,a]=cheby1(n,rp,wn,'stop'); w=0:0.1/pi:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,2,4); plot(om/pi,m); ylabel('gain'); xlabel('d'); INPUT: enter the passband ripple.3 enter the stop band ripple46 enter the psaaband freq1400 enter the stopband freq2000 enter the sampling freq8000 OUTPUT: CHEBYSHEV -2 INFINITE IMPULSE RESPONSE FILTER clc; close all; clear all; format long rp=input('enter the passband ripple'); rs=input('enter the stop band ripple'); wp=input('enter the psaabandfreq'); ws=input('enter the stopbandfreq'); fs=input('enter the sampling freq'); w1=2*wp/fs; w2=2*ws/fs; [n,wn]=cheb2ord(w1,w2,rp,rs); [b,a]=cheby1(n,rp,wn); w=0:.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,2,1); plot(om/pi,m); ylabel('gain'); xlabel('a'); [b,a]=cheby2(n,rs,wn,'high'); w=0:.01/pi:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,2,2); plot(om/pi,m); ylabel('gain'); xlabel('a'); wn=[w1 w2]; [b,a]=cheby2(n,rs,wn,'bandpass'); w=0:0.01:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,2,3); plot(om/pi,m); ylabel('gain'); xlabel('c'); wn=[w1 w2]; [b,a]=cheby2(n,rs,wn,'stop'); w=0:0.1/pi:pi; [h,om]=freqz(b,a,w); m=20*log10(abs(h)); an=angle(h); subplot(2,2,4); plot(om/pi,m); ylabel('gain'); xlabel('d'); RESULT OUTPUT: MULTIRATE FILTERS INTERPOLATION clc; close all; clear all; N=31; Nord=N-1; L=3; ro1=.2; h1=firnyquist(Nord,L,ro1); ro2=.4; h2=firnyquist(Nord,L,ro2); ro3=.6; h3=firnyquist(Nord,L,ro3); figure(1) subplot(3,1,1); stem(0:N-1,h1,'b'); axis([0,30,-.2,.5]); ylabel('h1(n)'); title('figure 1'); legend('h1') subplot(3,1,2); stem(0:N-1,h2,'k'); axis([0,30,-.2,.5]); ylabel('h2'); legend('h2') subplot(3,1,3) stem(0:N-1,h3,'r'); axis([0,30,-.2,.5]); ylabel('h3(n)'); xlabel('n'); legend('h3') [H1,f]=freqz(h1,1,256,2); [H2,f]=freqz(h2,1,256,2); [H3,f]=freqz(h3,1,256,2); figure(2) plot(f,abs(H1),'b',f,abs(H2),'k',f,abs(H3),'r'); grid title('fig2'); axis([0,1,0,1.1]); xlabel('\omega/\pi'); ylabel('mag'); legend('|H_1(e^j^\omega)|''|H_2(e^j^\omega)|''|H_3(e^j^\omega)|') OUTPUT: DECIMATOR close all; clear all; % Computing the coefficients of the Lth-band decimation filter: N =29; % Filter length Nord = N-1; % Filter order L = 4; ro = 0.2; % Roll-off factor h = firnyquist(Nord,L,ro); % Filter design [H,f] = freqz(h,1,500,2); % Computing the frequency response figure (1) subplot(2,1,1) stem(0:N-1,h); xlabel('n'); ylabel('h[n]'); title('Figure 1') axis([0,N-1,-0.1,0.3]) subplot(2,1,2) plot(f,20*log10(abs(H))), xlabel('\omega/\pi'), ylabel('Gain, dB') axis([0,1,-60,2]), grid % Polyphase components of the decimation filter h[n] e0 = downsample(h,4,0); e1 = downsample(h,4,1); e2 = [0,0,0,0.25,0,0,0]; e3 = downsample(h,4,3); % Generating the original signal x[n] n = 0:255;x = cos(pi*0.15*n)+cos(pi*0.55*n); [X,f] = freqz(x,1,500,2); figure (2) plot(f,abs(X)) xlabel('\omega/\pi'); ylabel('Amplitude') title('Figure 2: Amplitude spectrum of the original signal, |X(e^j^\omega)|') % Polyphasedownsampling of the original signal x0 = [x(1:4:256),0]; x1 = [0,x(4:4:256)]; x2 =[0,x(3:4:256)]; x3 = [0,x(2:4:256)]; % Polyphase filtering y0 = filter(e0,1,x0); y1 = filter(e1,1,x1); y2 = 0.25*[0,0,0,x2(1:length(x2)-3)]; y3 = filter(e3,1,x3); % Decimated signal y[n] y = y0+y1+y2+y3; [Y,fd] = freqz(y,1,500,2); figure (3) ; plot(fd,abs(Y)) xlabel('\omega/\pi'); ylabel('Amplitude'); title('Figure 3: Amplitude spectrum of the decimatedl signal, |Y(e^j^\omega)|') OUTPUT :(RESAMPLING) RESAMPLING clear all, close all % STEP 1 h = firhalfband(22,0.4); % FIR filter design % Generation of the input signal F = [0,0.05,0.45,1]; A = [0,1,0.1,0.05]; x1 = fir2(256,F,A); x2 = sin(2*pi*(0:256)*0.4)/150; x = x1 + x2; [X,f] = freqz(x,1,512,2); % Spectrum of the original signal figure (2) plot(f,abs(X(1:512))),; xlabel('\omega/\pi'; ylabel('|X(e^{j\omega})|'); title('Figure 2: Spectrum of the original signal') axis([0,1,0,1.1]) % Polyphase decomposition e0 = h(1:2:(length(h)-1)/2); % Setting the initial states xk = zeros(size(1:(length(h)+1)/2)); % Decimation rot = 0; % Initial switch position y = []; for n=1:length(x) xn = x(n); if rot==0 ss=1; pro = xn*e0; xk = [pro+xk(1:length(xk)/2),fliplr(pro) + xk((length(xk)/2+1):length(xk))]; yn = xk(length(xk)); y = [yn,y]; xk = [0,xk(1:length(xk)-1)]; else end if rot==1 ss=0; xk(length(xk)/2+1) = 0.5*xn + xk(length(xk)/2+1); else end rot=ss; end Y = freqz(y,1,512,2); % Spectrum of the decimated signal figure (3) plot(f,abs(Y(1:512))), xlabel('\omega/\pi'),ylabel('|Y(e^{j\omega})|') title('Figure 3: Spectrum of the decimated signal') axis([0,1,0,0.6]) % STEP 2 % Interpolation according to Figure 1 yi=[]; xk=zeros(size(1:(length(h)+1)/2)); rot=0; k=1; for n=1:length(y)*2-1 xn=y(k); if k==1, xk=[xn,xk(1:length(xk)-1)]; else end if rot==0 ss=1; yn=2*sum((xk(1:length(xk)/2)+fliplr(xk(length(xk)/2+1:length(xk)))).*e0); yi=[yi,yn]; OUTPUT: elsee nd if rot==1 ss=0; yi=[yi,xk(length(xk)/2)]; if k>1 xk=[xn,xk(1:length(xk)-1)]; else end k=k+1; else end rot=ss; end [Yi,f]=freqz(yi,1,512,2); % Spectrum of the interpolated signal figure(4) plot(f,abs(Yi)); title('Figure3: Spectrum of the interpolated signal') xlabel('\omega/\pi'); ylabel('|(Y_i)|') RESULT OUTPUT: EQUALIZATION clc; clear all; close all; M=3000; T=2000; L=20; ChL=5; (ChL+1) EqD=round((L+ChL)/2); Ch=randn(1,ChL+1)+sqrt(1)*randn(1,ChL+1); Ch=Ch/norm(Ch); TxS=round(rand(1,M))*2-1; TxS=TxS+sqrt(1)*(round(rand(1,M))*2-1); x=filter(Ch,1,TxS); n=randn(1,M); %+sqrt(-1)*randn(1,M); e(i)=TxS(i+10+L-EqD)-c'*X(:,i+10); c=c+mu*conj(e(i))*X(:,i+10); endsb=c' *X; sb1=sb/norm(c); sb1=sign(real(sb1))+sqrt(-1)*sign(imag(sb1)); start=7; sb2=sb1-TxS(start+1:start+length(sb1)); SER=length(find(sb2~=0))/length(sb2); disp(SER); subplot(2,2,1), plot(TxS,'*'); grid; title('Input symbols'); xlabel('real part'), ylabel('imaginary part') axis([-2 2 -2 2]) subplot(2,2,2), plot(x,'o'); grid, title('Received samples'); xlabel('real part'), ylabel('imaginary part') subplot(2,2,3), plot(sb,'o'); grid, title('Equalized symbols'), xlabel('real part'), ylabel('imaginary part') subplot(2,2,4), plot(abs(e)); grid, title('Convergence'), xlabel('n'), ylabel('error signal') RESULT OUTPUT enter value for m4 enter value for n4 Enter values for i/p 1234 Enter Values for n1234 The Value of output y[0]=1 The Value of output y[1]=4 The Value of output y[2]=10 The Value of output y[3]=20 The Value of output y[4]=25 The Value of output y[5]=24 The Value of output y[6]=16 LINEAR CONVOLUTION USING TMS320C5416 PROGRAM #include<stdio.h>intx [15],h[15],y[15]; main() { inti,j,m,n; printf("\n enter value for m"); scanf("%d",&m); printf("\n enter value for n"); scanf("%d",&n); printf("Enter values for i/p x(n):\n"); for(i=0;i<m;i++) scanf("%d",&x[i]); printf("Enter Values for i/p h(n) \n"); for(i=0;i<n; i++) scanf("%d",&h[i]); / padding of zeros for(i=m;i<=m+n-1;i++); for(i=n;i<=m+n-1;i++) h[i]=0; /* convolution operation */ for(i=0;i<m+n-1;i++) { y[i]=0; for(j=0;j<=i;j++) { y[i]=y[i]+(x[j]*h[i-j]); }} //displaying the o/p for(i=0;i<m+n-1;i++) printf("\n The Value of output y[%d]=%d",i,y[i]); } RESULT OUTPUT:Enter the length of the first sequence 4 Enter the length of the second sequence 3 Enter the first sequence 1 2 3 4 Enter the second sequence 1 2 3 The circular convolution is 18 16 10 16 CIRCULAR CONVOLUTION USING TMS320C5416 PROGRAM #include<stdio.h> intm,n,x[30],h[30],y[30],i,j, k,x2[30],a[30]; void main() { printf(" Enter the length of the first sequence\n"); scanf("%d",&m); printf(" Enter the length of the second sequence\n"); scanf("%d",&n); printf(" Enter the first sequence\n"); for(i=0;i<m;i++) scanf("%d",&x[i]); printf(" Enter the second sequence\n"); for(j=0;j<n;j++) scanf("%d",&h[j]); if(m-n!=0) /*If length of both sequences are not equal*/ { if(m>n) /* Pad the smaller sequence with zero*/ { for(i=n;i<m;i++) h[i]=0; n=m; } for(i=m;i<n;i++) x[i]=0; m=n; } y[0]=0;a[0]=h[0];for(j=1;j<n;j++) /*folding h(n) to h(-n)*/ a[j]=h[n-j]; /*Circular convolution*/ for(i=0;i<n;i++) y[0]+=x[i]*a[i];for(k=1;k<n;k++ ) { y[k]=0; /*circular shift*/ for(j=1;j<n;j++) x2[j]=a[j-1];x2[0]=a[n-1];for(i=0;i<n;i++) { a[i]=x2[i];y[k]+=x[i]*x2[i]; } } /*displaying the result*/ printf(" The circular convolution is\n"); for(i=0;i<n;i++) printf("%d \t",y[i]); } RESULT OUTPUT FIR LOWPASS FILTER FIR HIGH PASS FILTER IMPLEMENTATION OF FIR FILTER USING TMS320C5416 PROGRAM #include<stdio.h> #include<math.h> #define pi 3.1415 intn,N,c; floatwr[64],wt[64]; void main() { printf("\n enter no. of samples,N= :"); scanf("%d",&N); printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :"); scanf("%d",&c); printf("\n elements of window function are:"); switch(c) { case 1: for(n=0;n<=N1;n++) { wr[n]=1; printf(" \n wr[%d]=%f",n,wr[n]); } break; case 2: for(n=0;n<=N-1;n++) { wt[n]=1-(2*(float)n/(N-1)); printf("\n wt[%d]=%f",n,wt[n]); } break; }} RESULT OUTPUT IIR LOWPASS FILTER IIR HIGH-PASS FILTER IMPLEMENTATION OF IIR FILTER USING TMS320C6713 //iirfilters #include<stdio.h> #include<math.h>in ti,w,wc,c,N; float H[100]; floatmul(float, int); void main() { printf("\n enter order of filter "); scanf("%d",&N); printf("\n enter the cutoff freq "); scanf("%d",&wc); printf("\n enter the choice for IIR filter 1. LPF 2.HPF "); scanf("%d",&c); switch(c) { case 1: for(w=0;w<100;w++) { H[w]=1/sqrt(1+mul((w/(float)wc),2*N)); printf("H[%d]=%f\n",w,H[w]); } break; case 2: for(w=0;w<=100;w++) { H[w]=1/sqrt(1+mul((float)wc/w,2*N)); printf("H[%d]=%f\n",w,H[w]); } break; }} floatmul(float a,int x) { for(i=0;i<x-1;i++) a*=a; return(a); } RESULT OUTPUT: SINEWAVE: COSINE WAVE: GENERATION OF WAVEFORMS USING TMS320C6713 PROGRAM: SINEWAVE: #include<stdio.h> #include<math.h> float a[100]; main() { int i; for(i=0;i<99;i++) { a[i]=sin(2*3.14*5*i/100); printf("%f",a[i]); } } COSINE WAVE #include<stdio.h> #include<math.h> float a[100]; main() { int i; for(i=0;i<99;i++) { a[i]=cos(2*3.14*5*i/100); printf("%f",a[i]); } } UNIT RAMP: #include<stdio.h> #include<math.h>in ta[50]; main() { int i; for(i=0;i<49;i++) { a[i]=i; printf("%d",i); } } UNIT RAMP: UNIT STEP: UNIT STEP: #include<stdio.h> #include<math.h>in ta[10]; main() { int i=1,j; for(j=0;j<9;j++) { a[j]=i; printf("%d",i); } } RESULT FFT INPUT FFT OUTPUT IMPLEMENTATION OF FFT USING TMS320C5416 fft.c #define PTS 64 typedefstruct{float real,imag;}COMPLEX; extern COMPLEX w[PTS]; void FFT(COMPLEX*Y,int N) { COMPLEX temp1,temp2; inti,j,k; intupper_leg,lower_leg; intleg_diff; intnum_stages=0; intindex,step; i=1; do { num_stages+=1; i=i*2; } while(i!=N); leg_diff=N/2; step=(PTS*2)/N; for(i=0;i<num_stages;i++) { index=0; for(j=0;j<leg_diff;j++) { for(upper_leg=j;upper_leg<N;upper_leg+=(2*leg_diff)) {lower_leg=upper_leg+leg_diff; temp1.real=(Y[upper_leg]).real+(Y[lower_leg]).real; temp1.real=(Y[upper_leg]).imag+(Y[lower_leg]).imag; temp2.real=(Y[upper_leg]).real+(Y[lower_leg]).real; temp2.imag=(Y[upper_leg]).imag+(Y[lower_leg]).imag; (Y[lower_leg]).real=temp2.real*(w[index]).real-temp2.imag*(w[index]).imag; (Y[lower_leg]).imag=temp2.real*(w[index]).real+temp2.imag*(w[index]).imag; (Y[upper_leg]).real=temp1.real; (Y[upper_leg]).imag=temp1.imag; } index+=step; } leg_diff=leg_diff/2; step*=2; } j=0; for(i=1;i<(N1);i++) { k=N/2; while(k<=j) { j=j-k; k=k/2; } j=j+k; if(i<j) temp1.real=(Y[j]).real; temp1.imag=(Y[j]).imag; (Y[j]).real=(Y[i]).real; (Y[j]).imag=(Y[i]).imag; (Y[i]).real=temp1.real; (Y[j]).imag=temp1.imag; } } return; } fft 256.c #include<math.h> #define PTS 64 #define PI 3.14159265358979 typedefstruct{float real,imag;}COMPLEX; void FFT(COMPLEX*Y,int n); floatiobuffer[PTS]; float x1[PTS]; short i; shortbuffercount=0; short flag=0; COMPLEX w[PTS]; COMPLEX samples[PTS]; main() { for(i=0;i<PTS;i++) { w[i].real=cos(2*PI*i/(PTS*2.0)); w[i].imag=-sin(2*PI*i/(PTS*2.0)); } for(i=0;i<PTS;i++) { iobuffer[i]=sin(2*PI*10*i/(PTS*2.0)); samples[i].real=0.0; samples[i].imag=0.0; } for(i=0;i<PTS;i++) { samples[i].real=iobuffer[i]; } for(i=0;i<PTS;i++) samples[i].imag=0.0; FFT(samples,PTS); for(i=0;i<PTS;i++) { x1[i]=sqrt(samples[i].real*samples[i].real+samples[i].imag*samples[i].imag); } } RESULT