Sei sulla pagina 1di 20

Experiment No.

1
Aim:Genration of different waveforms square,sine,triangular ,exponential. Apparatus: MATLAB Software Program: % Square wave t=0:0.01:10; x=square (t/2*pi); % figure subplot(2,2,1) plot(t,x); xlabel('Time in second'); ylabel('Amplitude'); title('Square Wave');

% Sine wave y=sin(t); %figure; subplot(2,2,2) plot(t,y); xlabel('Time in second'); ylabel('Amplitude'); title('Sine Wave');

%Traiangular Wave k=1; for i=0:pi/2:4*pi z(k)=sin(i); 1|Page

k=k+1; end subplot(2,2,3) plot(z); xlabel('Time in second'); ylabel('Amplitude'); title('Triangular Wave');

%Exponential Function n=1; for j=0:0.01:10 e(n)=exp(j); n=n+1; end subplot(2,2,4) plot(e); xlabel('Time in second'); ylabel('Amplitude'); title('Exponential Function');

2|Page

3|Page

Experiment No.2
AIM:Program for convolution of two sequences [y(n)=x1(n)*x2(n)]. Apparatus: MATLAB Software Program: x1=input('enter the first sequence x1(n)='); x2=input('enter the first sequence x2(n)='); % starting point of first sequence nx1=input('enter the range of first sequence [-n:n]='); % starting point of second sequence nx2=input('enter the range of second sequence [-n:n]='); nyb=nx1(1)+nx2(1); nye=nx1(length(x1))+nx2(length(x2)); ny=[nyb:nye]; y=conv(x1,x2) stem(ny,y);

Output:

4|Page

5|Page

Experiment No.3
AIM:Program to check the performance of linear difference equation. Apparatus: MATLAB Software Program: %This program is used to calculate the output of a system %which is described by linear difference equation %Example %Let the difference equation be %y(n)-0.9y(n)=x(n)and %coefficients are b=[1];a=[1,-0.9]; a=input('Enter the coefficient of input x='); b=input('Enter the coefficient of input y='); impz(a,b); title('impulse Response'); xlabel('n'); ylabel('h(n)') Output:

6|Page

7|Page

Experiment No.4
AIM:Compute and plot poles and zeros of Z-transform. Apparatus: MATLAB Software Program: %Z-transform is basically used for checking the system stability and poles and %zeros characterizes the system performance.User has to give numerator and %denominator polynomial. NUM=input(input the numerator polynomial:); DEN= input(input the denominator polynomial:); TRANF=tf(NUM,DEN(); [ZEROS POLES GAIN]=tf2zp(NUM,DEN); %disp(poles of transfer function are); %disp(Poles)%disp(Zeros of transfer function are); %disp(ZEROS) %disp(Gain of transfer function is); %disp(GAIN) %zplane(NUM,DEN) Output:

8|Page

9|Page

Experiment No.5
AIM:Program for finding magnitude and phase response of LTI system described by Transfer function H(z). Apparatus: MATLAB Software Program: LENGTH=input(input the length of DFT(For best result in power of 2):); THETA=0:pi/LENGTH:pi; NUM=[0.05 0.033 0.008]; DEN=[0.06 4 1]; TRANSFER=tf(NUM,DEN) [FREQ,W]=freqz(NUM,DEN,LENGTH); grid on; figure(1); subplot(2,1,1) k=0.2; plot(abs(FREQ),k); disp(abs(FREQ)); title(Magnitude response); xlabel(FREQ index); ylabel(Magnitude); grid on; subplot(2,1,2) disp(angle(FREQ)); plot(angle(FREQ),k); title(Phase response); xlabel(Frequency index); ylabel(Phase); 10 | P a g e

grid on; Output:

11 | P a g e

Experiment No.6
AIM:Find the N point circular or linear convolution using circular convolution of the ginen two Sequences. Apparatus: MATLAB Software Program: %Circular convolution of given two sequences given by user. %Convolution in time domain is simple multiplication in frequency domain

A_FIRST=input('Enter the elements of first sequence='); B_FIRST=input('Enter the elements of Second sequence='); LENGTH=length(A_FIRST); FFT_A_FIRST=fft(A_FIRST); FFT_B_FIRST=fft(B_FIRST); TEMP1(1)=B_FIRST(1); for i=2:LENGTH TEMP1(i)=B_FIRST(LENGTH+2-i); end %CIRCULAR CONVOLUTION for i=1:LENGTH sum=0; for j=1:LENGTH sum=sum+A_FIRST(j)*TEMP1(j); end conv(i)=sum; TEMP2(1)=TEMP1(LENGTH); for k=2:LENGTH TEMP2(k)=TEMP1(k-1); 12 | P a g e

end TEMP1=TEMP2; end disp('Convolved sequence1s:'); disp(conv); figure(1) subplot(3,1,1) stem(A_FIRST,'k'); title('First input sequence'); subplot(3,1,2) stem(B_FIRST,'k'); title('second input sequence'); subplot(3,1,3) stem(conv,'k'); title('Convolved sequence'); Output:

13 | P a g e

14 | P a g e

Experiment No.7
AIM: Program for designing an IIR Filter . Apparatus: MATLAB Software Program: % This program Take the Digital filter specification % wp digital passband frequency % ws digital stop band frequency,Rp Passband ripple % As Stopband attenuation % Example:wp=0.2*pi;ws=0.3*pi; % Rp=1;As=15;

wp=input('Enter the digital passband frequency'); ws=input('Enter the digital stopband frequency'); Rp=input('Enter the passband ripple'); As=input('Enter the stop band attenuation'); T=1; Omegap=(2/T)*tan(wp/2); %prewarp Prototype Passband freq. Omegas=(2/T)*tan(ws/2); %prewarp Prototype Passband freq.

% Analog Prototype Calculation N=ceil((log10((10^(Rp/10)-1)/(10^(As/10)-1)))/(2*log10(Omegap/Omegas))); % fprint('Butterworth filter order=%2.0f/',N); OmegaC=Omegap/((10^(Rp/10)-1)^(1/(2*N))); % analog BW prototype cutoff wn=2*atan((OmegaC*T)/2);

% Digital filter design 15 | P a g e

wn=wn/pi %Digital Butter cutoff in pi [b,a]=butter(N,wn); Output:

16 | P a g e

Experiment No.8
AIM: Program for designing an low- pass FIR Filter . Apparatus: MATLAB Software Program: % Windows:a.Hamming window. % b.hanning window. % The FIR filters are designed with the window functions which are the' % empirical formulae. % The simple example of the filter is simulated using 'SINC' function. % The filter coefficient are calculated for respective window function i.e. % W(n).Then point-wise multiplication of H(n)and W(n) will give Fitered response,user can see the difference is clear from the graphical diagram itself.

N=input('Input order of the filter:');%ORDER of filter.

% TRANSFER FUNCTION EVALUATION. THETA=-pi:(2*pi/(N-1)):pi; Hn=sinc(THETA); disp('Original sequence is'); disp(Hn);

% HANNING RESPONSE. Wn_HANN=hanning(N); disp('Filter coefficients with Hanning window are'); disp(Wn_HANN); FILTER_RESP_HANN=(Hn').*Wn_HANN; 17 | P a g e

disp('Filtered response with Hanning window is:'); disp(FILTER_RESP_HANN); figure(1); subplot(2,1,1); plot(Hn,'k'); title('Original sequence'); subplot(2,1,2); plot(FILTER_RESP_HANN,'k'); title('Filtered response with Hanning window');

% HAMMING RESPONSE. Wn_HAMM=hamming(N); disp('Filter coefficients with Hamming window are'); disp(Wn_HAMM); FILTER_RESP_HAMM=(Hn').*Wn_HAMM; disp('Filtered response with Hamming window is:'); disp(FILTER_RESP_HAMM); figure(2); subplot(2,1,1); plot(Hn,'k'); title('Original sequence'); subplot(2,1,2); plot(FILTER_RESP_HAMM,'k'); title('Filtered response with Hamming window'); Output:

18 | P a g e

19 | P a g e

20 | P a g e

Potrebbero piacerti anche