You are on page 1of 15

EXPERIMENT NO.

1
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 -->');

(BASIC SIGNALS)

a) %PROGRAM FOR THE GENERATION OF UNIT IMPULSE SIGNAL

b) %PROGRAM FOR THE GENERATION OF UNIT STEP SEQUENCE [U(N)- U(N-N)] n=input('Enter the value of n'); t=0:1:n-1; y1=ones(1,n); subplot(2,2,2); stem(t,y1); ylabel('amplitude -->'); xlabel('(b) n -->'); c) %PROGRAM FOR 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 -->'); d) %PROGRAM FOR GENERATION OF EXPONENTIAL SEQUENCE n3=input('enter the length of exponential sequence'); t=0:n3; a=input('Enter the value of a'); y3=exp(a*t); subplot(2,2,4); stem(t,y3); ylabel('amplitude -->'); xlabel('(d) n -->');

OUTPUTS

1 amplitude --> -1 0 (a) n --> 1 2 amplitude -->

0.5

0.5

0 -2

2 (b) n -->

8 amplitude --> amplitude --> 6 4 2 0

1500

1000

500

4 (c) n -->

4 (d) n -->

EXPERIMENT NO.2 (DISCRETE CONVOLUTION AND CORRELATION)


a) % PROGRAM FOR THE LINEAR CONVOLUTION OF THE SEQUENCE clc; clear all; close all; x=input('Enter the first seq:'); h=input('Enter the second seq:'); y=conv(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(y); ylabel('amplitude-->'); xlabel('(c) n-->'); disp('The resultant signal is:');

OUTPUT: Enter the first seq:[1 2] Enter the second seq:[1 2 4] The resultant signal is: y= 1 4 8 8

amplitude-->

2 1 0

1.1

1.2

1.3

1.4

1.5 (a) n-->

1.6

1.7

1.8

1.9

amplitude-->

4 2 0

1.2

1.4

1.6

1.8

2 (b) n-->

2.2

2.4

2.6

2.8

amplitude-->

10 5 0

1.5

2.5 (c) n-->

3.5

b) % PROGRAM FOR COMPUTING CROSS CORRELATION OF THE SEQUENCES clc; clear all; close all; x=input('Enter the first seq:'); h=input('Enter the second seq:'); 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(y); ylabel('amplitude-->'); xlabel('(c) n-->'); disp('The resultant signal is:');y

OUTPUT Enter the first seq:[1 2] Enter the second seq:[2 3 7 5] The resultant signal is: y= 5.0000 17.0000 17.0000 8.0000 4.0000 0 0

amplitude-->

2 1 0

1.1

1.2

1.3

1.4

1.5 (a) n-->

1.6

1.7

1.8

1.9

amplitude-->

10 5 0

1.5

2.5 (b) n-->

3.5

amplitude-->

20 10 0

4 (c) n-->

c) %PROGRAM FOR COMPUTING AUTO CORRELATION OF THE SEQUENCES clc; clear all; close all; x=input('Enter the seq:'); y=xcorr(x,x); figure; subplot(2,1,1); stem(x); ylabel('amplitude-->'); xlabel('(a) n-->'); subplot(2,1,2); stem(y); ylabel('amplitude-->'); xlabel('(b) n-->'); disp('The resultant signal is:');y

OUTPUT: Enter the seq:[1 2 3 4] The resultant signal is: y= 4.0000 11.0000 20.0000 30.0000 20.0000 11.0000 4.0000

4 amplitude--> 3 2 1 0

1.5

2.5 (a) n-->

3.5

30 amplitude-->

20

10

4 (b) n-->

EXPERIMENT NO.3 (TRIGNOMETRIC SEQUENCES)


% WRITE A PROGRAM TO IMPLEMENT SINE, COSINE WAVEFORM clc; N=30; x=ones(1,N); n=0:1:N-1; subplot(3,1,1);stem(x); ylabel('x(n)');xlabel('n---->'); title('Unit step sequence'); y=sin(.1*pi*n); subplot(3,1,2);stem(y); ylabel('x(n)');xlabel('n---->'); title('Sine function'); z=cos(.1*pi*n); subplot(3,1,3);stem(z); ylabel('x(n)');xlabel('n---->'); title('Cosine function');

OUTPUT
Impulse,sine &cosine

EXPERIMENT NO.4 (MATRIX INVERSE)


%PROGRAM TO COMPUTE INVERSE OF MATRIX EQUATION Ax=Y clc; clear all; close all; A=input('Enter a square matrix A'); [m,n]=size(A); if(m==n) Y=input('Enter another matrix Y having size of columns equal to no. of rows of matrix A'); [q,r]=size(Y); if(n==q) disp('The inverse of the matrix equation Ax=Y'); disp('x (using inverse (inv) function) = '); disp(inv(A)*Y); disp('x(using matrix left division "\" operator or midivision(A,Y)function)= '); disp(A\Y); else disp('The size of the columns of given matrix Y is not equal to the no. of rows of square matrix A'); end else disp('Given matrix A is not a square matrix '); end

%OUTPUT
Enter a square matrix A[5 9 55;3 6 2;20 15 87] Enter another matrix Y having size of columns equal to no. of rows of matrix A [2 6;1 5;9 7] The inverse of the matrix equation Ax=Y x (using inverse (inv) function) = 0.4877 -0.2677 -0.0788 0.9759 0.0049 -0.0263 x(using matrix left division "\" operator or midivision(A,Y)function)= 0.4877 -0.2677 -0.0788 0.9759 0.0049 -0.0263

EXPERIMENT NO.5 (MATRIX EIGEN)


%PROGRAM TO COMPUTE EIGEN VALUES AND EIGEN VECTORS OF A MATRIX clc; clear all; close all; A = input('Enter a square matrix A'); [m,n]=size(A); if(m==n) [V,D]=eig(A); disp('Eigen Vectors = '); disp(V); disp('Matrix of Eigen Values = '); disp(D); disp('Vector of Eigen Values = '); disp(eig(A)); else disp('Given Matrix A is not a Square Matrix '); end

%OUTPUT Enter a square matrix A[5 6 4;9 1 66;22 10 3] Eigen Vectors = -0.2287 -0.3718 0.2113 -0.8756 0.9241 -0.9484 -0.4254 -0.0887 0.2364 Matrix of Eigen Values = 35.4129 0 0 0 -8.9574 0 0 0 -17.4555 Vector of Eigen Values = 35.4129 -8.9574 -17.4555

EXPERIMENT NO.6 (MATRIX DETERMINANT)


%PROGRAM TO COMPUTE DETERMINANT OF A MATRIX clc; clear all; close all; A = input('Enter a square Matrix A'); [m,n]=size(A); if(m==n) disp('Determinant of Matrix A = '); disp(det(A)); else disp('Given Matrix is not a Square Matrix'); end

%OUTPUT Enter a square Matrix A [5 2 6; 10 63 98;1 3 8] Determinant of Matrix A = 888

EXPERIMENT NO.7 (FAST FOURIER TRANSFORM)


%PROGRAM TO COMPUTE FAST FOURIER YTRANSFORM(FFT) clc; n=input('Enter the number of points:'); x=input('Enter the sequence:'); z=fft(x,n); disp('FFT of the input sequence is:');z subplot(2,1,1);stem(real(x),imag(x)); xlabel('real');ylabel('imaginary'); subplot(2,1,2);stem(real(z),imag(z)); xlabel('real');ylabel('imaginary');

%OUTPUT Input sequence, x(n):[4 5 7 9 10] z= Columns 1 through 4 35.0000 Column 5 -4.3090 - 5.9309i -4.3090 + 5.9309i -3.1910 + 1.0368i -3.1910 - 1.0368i

You might also like