Professional Documents
Culture Documents
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)
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
0.5
0.5
0 -2
2 (b) n -->
1500
1000
500
4 (c) n -->
4 (d) n -->
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.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
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.6
1.7
1.8
1.9
amplitude-->
10 5 0
1.5
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
3.5
30 amplitude-->
20
10
4 (b) n-->
OUTPUT
Impulse,sine &cosine
%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
%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
%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