You are on page 1of 55

BASIC SIMULATION

LAB RECORD

K.Sahithi
09071A0489

Operations on the matrix
AIM: Create a matrix
PROCEDURE:
x=[1 2 3]
x=
1 2

3

% find its transpose
x'
ans =
1
2
3

AIM: Create a row matrix with elements j,2+4j,-3+4j
PROCEDURE:
a=[1*j 2+4*j -3+4*j]
a=
0 + 1.0000i 2.0000 + 4.0000i -3.0000 + 4.0000i
% find its transpose
a'
ans =
0 - 1.0000i
2.0000 - 4.0000i
-3.0000 - 4.0000i

AIM:Create a row matrix, find sum of elements of matrix
PROCEDURE:
b=[4 5 7 9 4]
sum(b)
b=
4

5

7

9

4

s=
29

AIM: To find average of elements of matrix:
PROCEDURE:
m=mean(b)
m=
5.8000

AIM:To find the number of elements of the matrix:
PROCEDURE:
l=length(b)
l=
5

AIM:To find maximum & minimum of the elements :
PROCEDURE:
m1=max(b)
m2=min(b)
m1 =
9
m2 =
4

AIM:To find product of all elements of matrix:
PROCEDURE:
p=prod(b)
p=

5040

AIM: To find sign of all the elements :
PROCEDURE:
s1=sign(b)
s1 =
1

1

1

1

1

AIM:To find the non-zero elements:
PROCEDURE:
f=find(b)
f=
1

2

3

4

5

AIM:To arrange the elements of the matrix in ascending order &
descending order:

PROCEDURE:
a1=sort(b,'ascend')
d=sort(b,'descend')
a1 =
4

4

5

7

9

d=
9

7

5

4

4

OPERATIONS ON MXN MATRICES
AIM:Create a mxn matrix & measure its size
PROCEDURE:
m1=[1 2 3 4;5 6 7 8;9 10 11 12]
m1 =
1
5
9

2
6
10

3 4
7 8
11 12

AIM:To measure its size:
PROCEDURE:
s=size(m1)
s=
3

4

AIM:To make a 3x2 matrix into 4x2 & 3x3 matrix
PROCEDURE:
m2=[1 2;3 4;5 6];
m2(4,: )=[7 8]
m2(4,: )=[]
m2( :,3)=[10;11;12]
m2 =
1
3
5
7

2
4
6
8

m2 =
1 2
3 4
5 6
m2 =
1 2
3 4
5 6

10
11
12

13 14 15] m3(5. 36x1: PROCEDURE: h=[1 2 3 4 5 6. 3x12. 9x4.: )=[] m3 = 1 4 7 10 13 2 3 5 6 8 9 11 12 14 15 m3 = 1 4 7 10 2 3 5 6 8 9 11 12 AIM:To make that 4x3 matrix into a 4x2 matrix PROCEDURE: m3( :.4 5 6.AIM:To make a 5x3 matrix into a 4x3 matrix: PROCEDURE: m3=[1 2 3.6 7 8 9 10 11] r1 = r1 = Columns 1 through 9 1 3 5 2 4 6 3 5 7 2 4 6 3 5 7 4 6 8 . 18x2.3 4 5 6 7 8. 1x36.2 3 4 5 6 7. 4x9.4 5 6 7 8 9.3)=[] m3 = 1 4 7 10 2 5 8 11 AIM:To create a 6x6 matrix & change it into 2x18. 12x3.7 8 9.10 11 12.5 6 7 8 9 10.

4.4) r3 = 1 5 4 8 2 6 5 9 3 7 6 10 4 3 7 6 5 4 8 7 6 5 9 8 2 6 5 9 3 7 6 10 4 8 7 11 r4=reshape(h.Columns 9 through 18 4 6 8 5 7 5 7 9 6 r2=reshape(h.9.2) r2 = 1 2 3 4 5 6 2 3 4 5 6 7 3 4 5 6 7 8 4 5 6 7 8 9 5 6 7 8 9 10 6 7 8 9 10 11 r3=reshape(h.18.9) r4 = 8 9 6 8 10 10 7 9 11 .

12) r6 = 1 2 3 4 5 6 2 3 4 5 6 7 r7=reshape(h.1 2 3 4 5 6 2 3 4 5 6 7 3 4 5 6 7 8 4 5 6 7 8 9 5 6 7 8 9 8 10 9 6 10 7 11 3 4 5 6 7 8 4 5 6 7 8 9 r5=reshape(h.12.36.3) r5 = 1 2 3 4 5 6 2 3 4 5 6 7 3 4 5 6 7 8 4 5 6 7 8 9 5 6 7 8 9 10 6 7 8 9 10 11 r6=reshape(h.3.1) r7 = 1 2 3 4 5 6 2 3 4 5 6 7 3 4 5 5 6 7 8 9 10 6 9 7 10 8 11 .

1.1 0 1.7 8 9] x= 1 1 7 2 0 8 3 1 9 .36) r8 = Columns 1 through 9 1 2 3 4 5 6 Columns 10 through 18 2 3 4 5 6 7 3 4 5 Columns 19 through 27 6 7 8 4 5 6 7 8 9 Columns 28 through 36 5 6 7 8 9 10 6 7 8 9 10 11 ARITHEMATIC OPERATIOS ON MATRICES x=[1 2 3.6 7 8 4 5 6 7 8 9 5 6 7 8 9 10 6 7 8 9 10 11 r8=reshape(h.

8 9 4] y= 1 4 8 2 5 9 3 6 4 AIM:To add 2 matrices: PROCEDURE: a2=x+y a2 = 2 5 15 4 6 5 7 17 13 AIM:To subtract 2 matrices: PROCEDURE: op1=x-y op1 = 0 -3 -1 0 -5 -1 0 -5 5 AIM:To multiply 2 matrices: PROCEDURE: op2=x*y op2 = 33 39 27 9 11 7 111 135 105 AIM:To divide 2 matrices: PROCEDURE: op=x/y op = 1.y=[1 2 3.1111 1.0000 2.4444 -0.0000 0 0 -2.0000 0 %exponential function op3=exp(x) op4=exp(y) .4 5 6.3333 -1.

0027 0./y o2 = 1.1 0 1.0027 8.0201 0.9810 op4 = 1.0e+003 * 0.0027 0.0000 1.*y o1 = 1 4 56 4 9 0 6 72 36 AIM:To divde individual elements of 2 matrices: o2=x.0e+003 * 0.0201 0.8889 2.1031 0.8 9 4] y= .8750 1.0000 0 0.op3 = 1.0027 0.2500 RELATIONAL OPERATIONS ON MATRICES x=[1 2 3.1484 2.0010 1.4034 0.1031 0.4 5 6.0546 0.0966 2.9810 8.0000 0.0074 0.0546 AIM:To raise matrix to the power : PROCEDURE: op5=x^2 op5 = 24 26 32 8 10 12 78 86 110 AIM:To multiply individual elements of 2 matrices: PROCEDURE: o1=x.1667 0.7 8 9] x= 1 2 3 1 0 1 7 8 9 y=[1 2 3.0074 0.2500 0.

1 4 8 2 5 9 3 6 4 AIM: To verify greater than Relation: PROCEDURE: ro1=x>y ro1 = 0 0 0 0 0 0 0 0 1 AIM:To verify lesser than Relation: PROCEDURE: ro2=x<y ro2 = 0 0 0 1 1 1 1 1 0 AIM: To verify greater than or equal to Relation: PROCEDURE: r03=x>=y r03 = 1 1 1 0 0 0 0 0 1 AIM: To verify lesser than or equal to Relation: PROCEDURE: r04=x<=y r04 = 1 1 1 1 1 1 1 1 0 AIM To verify equal to Relation: PROCEDURE: r05=x==y r05 = 1 0 0 1 0 0 1 0 0 .

LOGICAL OPERATIONS ON MATRICES AIM: To verify AND operaton: PROCEDURE: lo1=x&y lo1 = 1 1 1 1 0 1 1 1 1 AIM: To verify OR aperation: PROCEDURE: lo2=x|y lo2 = 1 1 1 1 1 1 1 1 1 AIM: To verify NOT operation: PROCEDURE: lo3=~x lo3 = 0 0 0 0 1 0 0 0 0 .

GENERATION OF SIGNALS AIM: To generate a impulse signal Procedure: t=0:4 i=[(t==3)] stem(t.i) TITLE: Impulse signal .

x) .length(t)) x(j)=1 stem(t.AIM: To generate a impulse signal Procedure: t=-5:5 for i=1:length(t) if t(i)==0 j=i end end x=zeros(1.

4)] stem(t.y.AIM: To generate a unit impulse function Procedure: t=0:4 y=[1 zeros(1.'m') axis([-5 5 0 2]) title('ploting an impulse at t=0') grid .

x.m') Title: unit step at t=0 .length(t)) for i=1:length(t) if t(i)==0 j=i. axis([-100 100 0 2]) plot(t. x=zeros(1.AIM: To generate a unit step function Procedure: t=-100:100. end end x(j:length(t))=1.'-.

AIM: To generate a stair case signal Procedure: t=-50:50 x=zeros(1.x) axis([-50 50 0 6]) grid Title: staircase wave form .length(t)) k=0 for i=1:length(t) if t(i)==0 j=i while j<length(t) k=k+1 x(j:j+10)=k j=j+10 end end end plot(t.

2 0.4 -0. plot(t.4 0.8 0.3 0.1 0.AIM: To generate sinusoidal pulse Procedure: f=1000 T=1/f.x) Title: unit sine wave 1 0. t=0:T/f:T.7 0.6 0.2 0 -0.9 1 -3 x 10 .4 0.8 0.5 0.6 -0.2 -0.6 0.8 -1 0 0. x=sin(2*pi*f*t).

01 .8 0. T=i/f.009 0.005 0. t=0:T/f:T.006 0.4 0.003 0. x=sin(2*pi*f*t).6 0. plot(t.001 0.002 0.008 0.007 0.8 -1 0 0.2 0 -0.4 -0.AIM: To generate sinusoidal pulse train Procedure: f=1000 i=10.6 -0.x) Title: continuous sine wave 1 0.004 0.2 -0.

x. x(1:200)=t(1:200). plot(t.length(t)).'--r') Title:triangular pulse .AIM: To generate sawtooth pulse Procedure: t=0:200 x=zeros(1.

x(1:500)=t(1:500).length(t)).AIM: To generate sawtooth pulse train Procedure: t=0:500. y1=zeros(1. x=zeros(1. for k=1:3 y1(k*length(t)+1:k*length(t)+length(t))=y1(1:length(t)) end plot(y1. y1=x.1000).'--r') Title: continuous sawtooth pulse train 500 450 400 350 300 250 200 150 100 50 0 0 500 1000 1500 2000 2500 .

1000). y1=zeros(1.AIM: To generate triangular pulse train Procedure: t=0:200. x(101:200)=100-t(1:100).'--r') Title: continuous triangular pulse 100 90 80 70 60 50 40 30 20 10 0 0 100 200 300 400 500 600 700 800 900 .length(t)). x=zeros(1. for k=1:3 y1(k*length(t)+1:k*length(t)+length(t))=y1(1:length(t)) end plot(y1. x(1:100)=t(1:100). y1=x.

AIM: To generate ramp function Procedure: %ramp t=0:100.'--r') Title: ramp signal 100 90 80 70 60 50 40 30 20 10 0 0 10 20 30 40 50 60 70 80 90 100 . x=t. plot(t.x.

C') Title: sinc function .x.AIM: To generate sinc function Procedure: f=10 T=1/f t=-pi:T:pi x=sin(2*pi*t).'-./t plot(t.

01 -0.002 0 0.008 0./t*f*pi*2 plot(t.5 0 -0.'-.5 3 2.5 1 0.01 .01:T/f:T x=sin(2*pi*f*t).x.m') Title: sinc function 7 4 x 10 3.%other way of sinc function: f=1000 i=10 T=i/f t=-0.004 -0.002 0.5 2 1.006 0.008 -0.006 -0.5 -1 -0.004 0.

5 4 4.ADDITION OF SIGNALS AIM: To generate add two sine signals Procedure: f1=1000 i=10 T1=i/f1 t1=0:T1/f1:T1 y=sin(2*pi*f1*t1) f2=1000 i=5 T2=i/f2 t2=0:T2/f:T2 y1=sin(2*pi*f2*t2) y2=y1+y subplot(3.006 0.1.5 1 1.5 3 3.007 0.001 0.5 4 4.01 1 0 -1 0 0.1.y2) Title: addition of two sinusoidal signals 1 0 -1 0 0.5 5 -3 x 10 2 0 -2 0 0.1.5 1 1.002 0.5 2 2.003 0.y1) subplot(3.1) plot(t1.005 0.5 3 3.5 2 2.3) plot(t2.009 0.5 5 -3 x 10 .y) subplot(3.004 0.2) plot(t2.008 0.

5 1 1.5 2 2.5 1 1.009 0.5 3 3.5 4 4.5 2 2.5 3 3.y) subplot(3.Substracion of signals AIM: To substarct a sine signal from another sine signal Procedure: f1=1000 i=10 T1=i/f1 t1=0:T1/f1:T1 y=sin(2*pi*f1*t1) f2=1000 i=5 T2=i/f2 t2=0:T2/f2:T2 y1=sin(2*pi*f2*t2) y2=y1-y subplot(3.1) plot(t1.3) plot(t2.y1) subplot(3.008 0.002 0.005 0.1.1.007 0.5 4 4.01 1 0 -1 0 0.003 0.2) plot(t2.004 0.y2) Title: substraction of 2 sinusoidal signals 1 0 -1 0 0.1.006 0.001 0.5 5 -3 x 10 .5 5 -3 x 10 2 0 -2 0 0.

5 3 3.008 0.5 3 3.*y subplot(3.1) plot(t1.Multiplication of signals AIM: To multiply two sine signals Procedure: f1=1000 i=10 T1=i/f1 t1=0:T1/f1:T1 y=sin(2*pi*f1*t1) f2=1000 i=5 T2=i/f2 t2=0:T2/f2:T2 y1=sin(2*pi*f2*t2) y2=y1.5 4 4.1.5 5 -3 x 10 1 0 -1 0 0.1.005 0.002 0.009 0.006 0.y) subplot(3.5 1 1.1.3) plot(t2.y2) Title: multiplication of 2 sinusoidal waves 1 0 -1 0 0.5 2 2.007 0.001 0.004 0.y1) subplot(3.5 4 4.01 1 0 -1 0 0.2) plot(t2.5 1 1.5 2 2.5 5 -3 x 10 .003 0.

for k=1:3 y1(k*(length(t)/4)+1:k*(length(t)/4)+(length(t)/4))=y1(1:(length(t)/4)) end subplot(3. x(1:500)=t(1:500).'--c') Title: Amplitude scaling sawtooth pulse train .SAWTOOTH PULSE TRAIN TRANSFORMATION AIM: To scale and shift a sawtooth pulse train 2X(t): PROCEDURE: t=0:2000.'--r') subplot(3.2.y1. y1=zeros(1. x=zeros(1.1000).2*y2.1) plot(t.length(t)).2) plot(t.2. y1=x.

1) plot(t.1000).2.X(-t): PROCEDURE: t=0:2000.y1.2) plot(-t. y1=x.'--r') subplot(3. x(1:500)=t(1:500). for k=1:3 y1(k*(length(t)/4)+1:k*(length(t)/4)+(length(t)/4))=y1(1:(length(t)/4)) end subplot(3.'--c') Title: Time reversal for sawtooth function .2.y2.length(t)). y1=zeros(1. x=zeros(1.

2. for k=1:3 y1(k*(length(t)/4)+1:k*(length(t)/4)+(length(t)/4))=y1(1:(length(t)/4)) end subplot(3.2.2) plot(t/3. x=zeros(1. y1=x.X(t/3): PROCEDURE: t=0:2000.1000).y1.'--r') subplot(3. x(1:500)=t(1:500).1) plot(t.'--c') Title: time scaling for sawtooth function .y2. y1=zeros(1.length(t)).

1) plot(t. y1=zeros(1.'--c') .2) plot(t-2. x(1:500)=t(1:500).2.length(t)). for k=1:3 y1(k*(length(t)/4)+1:k*(length(t)/4)+(length(t)/4))=y1(1:(length(t)/4)) end subplot(3.'--r') subplot(3.y1.2. y1=x.y2.X(t-2): PROCEDURE: t=0:2000. x=zeros(1.1000).

TRIANGULAR PULSE TRAIN TRANSFORMATION AIM: To scale and shift a triangular pulse train X(t)-4: Procedure: t=0:40 x=zeros(1.1) plot(t.2) plot(t.200) y1=x for k=1:4 y1(k*(length(t)/2)+1:k*(length(t)/2)+(length(t)/2))=y1(1:(length(t)/2)) end subplot(3.'--r') subplot(3.length(t)) x(1:20)=t(1:20) x(21:40)=20-t(1:20) y1=zeros(1.x-4.'--m') 20 20 10 10 0 0 0 10 20 30 40 -10 0 10 20 30 40 .2.x.2.

2) plot(t-2.200) y1=x for k=1:4 y1(k*(length(t)/2)+1:k*(length(t)/2)+(length(t)/2))=y1(1:(length(t)/2)) end subplot(3.x.X(t-2): Procedure: t=0:40 x=zeros(1.x.'--r') subplot(3.2.1) plot(t.length(t)) x(1:20)=t(1:20) x(21:40)=20-t(1:20) y1=zeros(1.2.'--m') 20 20 10 10 0 0 10 20 30 40 0 -20 0 20 40 .

99 -1.003 0.986 1 0 -1 0 0.1.992 -1.'--c') subplot(3.005 0.998 -1.SINE WAVE TRANSFORMATION AIM: To scale a sinesoidal pulse train Procedure: f=2000 i=20 T=i/f t=0:T/f:T x=sin(2*pi*f*t) subplot(3.006 0.002 0.008 0.988 -1.996 -1.004 0.x.01 .007 0.2) plot(t.1.994 -1.001 0.'--m') 1 0 -1 -2 -1.009 0.x.1) plot((t-2).

'--m') subplot(2.length(t)) for i=1:length(t) if t(i)==0 j==i end end x1(j+50:length(t))=1 x2(j-50:length(t))=1 x3=x2-x1 subplot(2.RECTANGULAR PULSE TRANSFORMATION AIM: To shift a rectangular pulse train Procedure: t=-200:200 x1=zeros(1.-x3.x3.length(t)) x2=zeros(1.3.1) plot(t/3.'--r') .2) plot(2*t.3.

length(t2)) y(length(x):length(y))=x y1=fliplr(y) ye=((y+y1)/2) yo=((y-y1)/2) subplot(3.1.2) plot(t2.TO FIND EVEN AND ODD PARTS OF A SIGNAL AIM: To find even and odd parts of IMPULSE SIGNAL PROCEDURE: t=[0 1 2 3] x=[-3 2 1 3] t1=-fliplr(t) t(1)=[] t2=[t1 t] y=zeros(1.3) plot(t2.1) plot(t2.1.ye) subplot(3.1.y) subplot(3.yo) TITLE(even and odd functions of impulse ) 5 0 -5 -3 -2 -1 0 1 2 3 -2 -1 0 1 2 3 -2 -1 0 1 2 3 2 0 -2 -4 -3 2 0 -2 -3 .

xo=(x-x1)/2. end end end x1=fliplr(x). xe=(x+x1)/2. subplot(3.x) subplot(3.2) plot(t.xe) subplot(3. for i=1:length(t) if t(i)==0 j=i.3) plot(t.1) plot(t.1.1. x(j:j+10)=k.AIM: To find even and odd parts of STEP SIGNAL PROCEDURE: t=-50:50. k=0. j=j+10. x=zeros(1.1.xo) TITLE(even and odd parts of step signal) . while j<length(t) k=k+1.length(t)).

ye) subplot(3.y) subplot(3.1.yo) TITLE(even and odd parts of sine signal) .3) plot(t2.1.length(t2)) y(length(x):length(y))=x y1=fliplr(y) ye=((y+y1)/2) yo=((y-y1)/2) subplot(3.2) plot(t2.AIM: To find even and odd parts of SINE SIGNAL PROCEDURE: f=1000 i=10 T=i/f t=0:T/f:T x=sin(2*pi*f*t) t1=-fliplr(t) t(1)=[] t2=[t1 t] y=zeros(1.1) plot(t2.1.

i)) end n=min(n1)+min(n2):max(n1)+max(n2) stem(n.:) end for i=1:length(x)+length(y)-1 c(i)=sum(a(:.length(x)+length(y)-1) for i=1:min(length(x).length(y)) a(i.y) title('convolution of signals') Enter the values of 1st sequence x= 1 2 3 4 Enter the time axis values of 1st sequence [-1 0 1 2] n1 = -1 0 1 2 Enter the values of 2nd sequence [4 7 8 9] y= 4 7 8 9 Enter time axis values for 2nd sequence [0 1 2 3] n2 = 0 1 2 3 .i:i+length(y)-1)=y end for i=1:min(length(x).length(y)).:)=x(i)*a(i.AIM: To find convolution of two signals PROCEDURE: x=input('enter first sequence') n1=input('enter the time axis values of 1st sequence') y=input('enter the values of 2nd sequence') n2=input('enter time axis values for 2nd sequence') a=zeros(min(length(x).c) z=conv(x.length(y)) a(i.

convolution of signals 70 60 50 40 30 20 10 0 -1 0 1 2 3 4 5 .

x2=rand(1. y4=y1+y2. y1=filter(x.y. if max(abs(y4-y3)<10^-14) disp('system is linear') else disp('system is non linear') end INPUT: enter coefficients of input vector[1 1] x= 1 1 enter coefficients of output vector[1] y= 1 enter no of elements of input sequence20 n= 20 OUTPUT: system is linear .LINEARITY AIM:to check the system for linearity PROCEDURE: x=input(' enter coefficients of input vector') y=input('enter coefficients of output vector') n=input('enter no of elements of input sequence') x1=rand(1.x1+x2).n).x2).y.n).y.x1). y3=filter(x. y2=filter(x.

n) y1=filter(x.x2.y.^2) y3=filter(x.x1.n) x2=rand(1.y.x1+x2.^2) y4=y1+y2 if max(abs(y4-y3)<10^-14) disp('system is linear') else disp('system is non linear') end INPUT: enter coefficients of input vector[2 4] x= 2 4 enter coefficients of output vector[5] y= 5 enter no of elements of input sequence10 n= 10 OUTPUT: system is non linear .y.^2) y2=filter(x.AIM:to check the a system for linearity PROCEDURE: x=input(' enter coefficients of input vector') y=input('enter coefficients of output vector') n=input('enter no of elements of input sequence') x1=rand(1.

if y2==y3 disp('time invariant system') else disp('time variant system') end INPUT: enter coefficients of input vector1 x= 1 enter coefficients of output vector1 y= 1 enter no of elements of input sequence10 n= 10 OUTPUT: Time variant system . x2(2:length(x3))=x1(1:length(x3)-1) y2(2:length(y1))=y1(1:length(y1)-1) y3=filter(x.length(x3)).y.x2). x3=fliplr(x1) x2=zeros(1.length(y1)). y1=filter(x.n)].n) zeros(1.x3) y2=zeros(1.TIME VARIANCE AIM: To check whether the system is time variant PROCEDURE: x=input(' enter coefficients of input vector') y=input('enter coefficients of output vector') \n=input('enter no of elements of input sequence') x1=[rand(1.y.

x1) y2=zeros(1.n) zeros(1. x2(2:length(x1))=x1(1:length(x1)-1) y2(2:length(y1))=y1(1:length(y1)-1) y3=filter(x.length(x1)).n)]. y1=filter(x.y.x2). if y2==y3 disp('time invariant system') else disp('time variant system') end INPUT: enter coefficients of input vector[1 1] x= 1 1 enter coefficients of output vector[2] y= 2 enter no of elements of input sequence10 n= 10 OUTPUT: Time invariant system .length(y1)). x2=zeros(1.AIM:To check whether the system is time variant PROCEDURE: x=input(' enter coefficients of input vector') y=input('enter coefficients of output vector') n=input('enter no of elements of input sequence') x1=[rand(1.y.

0000 System is stable .STABILITY AIM: To find stability of given system PROCEDURE: a=input('enter the coefficients of output function') b=input('enter the coeficients of input function') p=roots(a) q=roots(b) if real(q(:))<0 disp('sys is stable') else disp('system is unstable') end INPUT: enter the coefficients of output function[1 3 2] a= 1 3 2 enter the coeficients of input function[1 5 6] b= 1 5 6 OUTPUT: p= -2 -1 q= -3.0000 -2.

1. if t(i)>=0.y.2) stem(t. end end h=filter(x. for i=1:length(t).x1) subplot(2.1.AIM: Computation of unit impulse response PROCEDURE: x=input('enter coeff of i/p vector') y=input('enter coeff of o/p vector') t=-10:10 x1=zeros(1.length(t)).h) xlabel('time axis') ylabel('impulse response') INPUT: enter coeff of i/p vector[1 1] x= 1 1 enter coeff of o/p vector1 y =1 OUTPUT: . x1(i)=1.x1) subplot(2.1) stem(t.

1) stem(t. x1(i)=1. end end h=filter(x.1.2) stem(t.x1) subplot(2. for i=1:length(t). if t(i)==0.length(t)).AIM: Computation of unit step response PROCEDURE: x=input('enter coeff of i/p vector') y=input('enter coeff of o/p vector') t=-10:10 x1=zeros(1.h) xlabel('time axis') ylabel(‘impulse response’) INPUT: enter coeff of i/p vector[1 1] x= 1 1 enter coeff of o/p vector1 y= 1 .1.y.x1) subplot(2.

1) plot(t.1.x) axis([0 f -2 2]) subplot(2.GIBBS PHENOMENON AIM: To find gibbs phenomenon PROCEDURE: fs=input('enter the sampling frequency'). q=x. x(i+length(t)/2)=-1.f.2) plot(t. t=linspace(0. for i=0:n-1 k=1/(2*i+1). for j=1:length(t) q(j)=q(j)+k*sin(t(j)/k). x=zeros(1.fs).length(t)). f=input('enter the duration of signal'). end end subplot(2. for i=1:length(t)/2 x(i)=1.q) INPUT: enter the sampling frequency100 enter the duration of signal6 enter num of sine waves4 OUTPUT: .1. end n=input('enter num of sine waves').

subplot(2. p=sym(-2).k.0) s1=int(exp(q*k-j*w*k).1.k.0).fs) xlabel('freqency') ylabel('magnitude of fourier transform of given signal) OUTPUT: g .-inf. s=s1+s2 w=(-5*2*pi*f:2*pi*f/100:5*2*pi*f)/f. x=exp(-1000*abs(t)). fs=subs(s.0.2) plot(w. r1=subs(r. r=exp(p*abs(k)).x) xlabel('time') ylabel('given signal') subplot(2. t=-5*T:T/100:5*T.k.w).1) plot(t.inf).1. s2=int(exp(p*k-j*w*k).FOURIER TRANSFORM AIM: To find the fourier transform of given signal PROCEDURE: syms w k f f=1000 T=1/f. q=sym(2).

theta.b.theta.b) y=int(cos(w*k). disp('auto corelation function ') disp(r) INPUT: p= 2 enter upper limit4 a= 4 enter lower limit2 b= 2 OUTPUT: x1 = 1/2*sin(2*w*t+w*k+2*theta) x= 1/2*sin(2*w*t+w*k+8)-1/2*sin(2*w*t+w*k+4) .STATINARITY AIM: To check a random process for stationarity PROCEDURE: syms A w t k theta p=sym(2) a=input('enter upper limit') b=input('enter lower limit') x1=int(cos(p*w*t+w*k+p*theta).theta.a)-subs(x1.theta) x=subs(x1.a) r=x+y.

X=input('enter the random process') M=d*int(X.AIM:checking for mean of random process PROCEDURE: syms A w t theta k rv=input('enter random variable') a=input('enter lower limit of random variable'). disp(M). d=1/(b-a).b).theta. INPUT: enter random variabletheta rv = theta OUTPUT: enter lower limit of random variable-pi enter upper limit of random variablepi enter the random process a*cos(w*t+theta) X= -pi*cos(w*t+theta) the mean of random process is 0 .a. disp('the mean of random process is'). b=input('enter upper limit of random variable').

0) R2=int(exp(p*k-j*w*k).w.-inf.0) R1=int(exp(q*k-j*w*k).k.-inf.inf) R=R1+R2 int(R.k.k.inf) disp('area enclosed ') disp(R/(2*pi)) OUTPUT: p= -2 q= 2 r= exp(-2*abs(k)) r1 = 1 R1 = -1/(-2+i*w) R2 = 1/(2+i*w) R= -1/(-2+i*w)+1/(2+i*w) ans = 2*pi area enclosed 1/2*(-1/(-2+i*w)+1/(2+i*w))/pi .AIM: Area enclosed by POWER SPECTRAL DENSITY PROCEDURE: syms w k thetas p=sym(-2) q=sym(2) r=exp(p*abs(k)) r1=subs(r.0.

Na Tum Jaano Na Hum http://portal.1/17 Mujhse Dosti Karoge!.beamtele.com/ .AIM: Checking for causality PROCEDURE: a=input('enter the numerator coefficients') b=input('enter the denominator coefficients') r1=input('enter the lower bound') r2=input('enter the upper bound') if r2==inf disp('system is causal') else disp('system is not causal') end INPUT: enter the numerator coefficients[1 2 1] a= 1 2 1 enter the denominator coefficients[1 5 6] b= 1 5 6 enter the lower bound2 r1 = 2 enter the upper bound5 r2 = 5 OUTPUT: system is not causal Main Prem Ki Diwani Hoon .