0% found this document useful (0 votes)
101 views26 pages

Signal and System File

The document describes experiments on generating and manipulating signals in signal processing. It includes generating unit sample sequences, unit step sequences, unit ramp sequences and real exponential sequences in continuous and discrete time. It also describes time shifting, time scaling, addition of signals, convolution of signals and solving difference equations for low pass and high pass filters. The experiments generate and plot various signals and their properties like impulse response and step response.

Uploaded by

Afraz Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views26 pages

Signal and System File

The document describes experiments on generating and manipulating signals in signal processing. It includes generating unit sample sequences, unit step sequences, unit ramp sequences and real exponential sequences in continuous and discrete time. It also describes time shifting, time scaling, addition of signals, convolution of signals and solving difference equations for low pass and high pass filters. The experiments generate and plot various signals and their properties like impulse response and step response.

Uploaded by

Afraz Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SIGNAL AND SYSTEM

AFRAZ KHAN
1616028
1

EXPERIMENT-1
AIM: GENERATION OF SIGNALS
(A): UNIT SAMPLE /IMPULSE SEQUENCE
(1) CONTINUOUS TIME :--
function[x,n]=impsequence(n0,n1,n2)
n=[n1:n2];
x=[(n-n0)==0];
plot(n,x);
end

OUTPUT:

(2) DISCRETE TIME :--


function[x,n]=impsequence(n0,n1,n2)
n=[n1:n2];
x=[(n-n0)==0];
stem(n,x);
end

OUTPUT:

Afraz Khan (1616028)


2

(B): UNIT STEP SIGNAL/SEQUENCE


(1): CONTINUOUS TIME
function[x,n]=impsequence(n0,n1,n2)
n=[n1:n2];
x=[(n-n0)>=0];
plot(n,x);
end

OUTPUT:

(2) DISCRETE TIME


function[x,n]=impsequence(n0,n1,n2)
n=[n1:n2];
x=[(n-n0)>=0];
stem(n,x);
end

OUTPUT:

Afraz Khan (1616028)


3

(C): UNIT RAMP SIGNAL SEQUENCE


(1): CONTINUOUS TIME
function[x,n]=impsequence(n0,n1,n2)
n=[n1:n2];
x1=(n>=0);
ramp=n.*x1;
plot(n,ramp);
end

OUTPUT:

(2): DISCRETE TIME


function[x,n]=impsequence(n0,n1,n2)
n=[n1:n2];
x1=(n>=0);
ramp=n.*x1;
stem(n,ramp);

Afraz Khan (1616028)


4

end

(D): REAL EXPONENTIAL SIGNAL/SEQUENCE


(1): ( 0 < ALPHA < 1 )
>> CONTINUOUS TIME
function[x,n]=realexponence(n1,n2)
n=[n1:n2];
x=(0.5).^n;
plot(n,x);
end

OUTPUT:

>>DISCRETE TIME
function[x,n]=realexponence(n1,n2)
n=[n1:n2];
x=(0.5).^n;
stem(n,x);
end

Afraz Khan (1616028)


5

OUTPUT:

(2): ( ALPHA >= 1 )


>> CONTINUOUS TIME
function[x,n]=realexponence(n1,n2)
n=[n1:n2];
x=(1.5).^n;
plot(n,x);
end

OUTPUT:

>> DISCRETE TIME


function[x,n]=realexponence(n1,n2)
n=[n1:n2];
x=(1.5).^n;
stem(n,x);

Afraz Khan (1616028)


6

end

OUTPUT:

(3): ( -1 < ALPHA < 0 )


>> CONTINUOUS TIME
function[x,n]=realexponence(n1,n2)
n=[n1:n2];
x=(-0.5).^n;
plot(n,x);
end

OUTPUT:

>> DISCRETE TIME


function[x,n]=realexponence(n1,n2)
n=[n1:n2];
x=(-0.5).^n;
stem(n,x);
end

Afraz Khan (1616028)


7

OUTPUT:

(4): ( ALPHA < -1 )


>> CONTINUOUS TIME
function[x,n]=realexponence(n1,n2)
n=[n1:n2];
x=(-1.5).^n;
plot(n,x);
end

OUTPUT:

>>DISCRETE TIME
function[x,n]=realexponence(n1,n2)
n=[n1:n2];
x=(-1.5).^n;
stem(n,x);

Afraz Khan (1616028)


8

end

OUTPUT:

(E): COMPLEX EXPONENTIAL SIGNAL/SEQUENCE


(1): CONTINUOUS TIME
function[x,n]=cmplxexpseq(n1,n2)
n=[n1:n2];
x=exp((-0.1 + 0.3*j)*n);
x1=real(x);
subplot(2,2,1);
plot(n,x1);
title('real part');
x2=imag(x);
subplot(2,2,2);
plot(n,x2);
title('imag part');
x3=abs(x);
subplot(2,2,3);
plot(n,x3);
title('magnitude');
x4=(180/pi)*angle(x);
subplot(2,2,4);
plot(n,x4);
title('phase shift');
end

OUTPUT:
complexseq(-10, 10)

Afraz Khan (1616028)


9

(2): ADDITION OF TWO SIGNALS


%ADDITON OF TWO SIGNALS WHERE x1[n] = [1,1,0,1,2,3,4,5] & x2[n]
=[1,0,2,1,1]
function[y,n]=sigadd(x1,n1,x2,n2)
%y = addition of sequence over n,which includes n1 amd n2
%x1 = first sequence over n1
%x2 = second sequence over n2 (n2 may not be equal to n1)
n = min(min(n1),min(n2)):max(max(n1),max(n2));%duration of y[n]
y1=zeros(1,length(n));
y2=y1;
y1(find((n>=min(n1))&(n<=max(n1))==1))= x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))= x2;
y = y1 + y2;
stem (n,y);
end

OUTPUT:

Afraz Khan (1616028)


10

EXPERIMENT -2
AIM: TIME SHIFTING AND TIME SCALING OF SIGNALS
(1): SIGNAL SHIFT
implement y[n]= {x[n-k]}
function[y,n]=sigshift(x,m,k)
%implements y[n] = x[n-k]
n=m+k;
y=x;
stem (n,y)
end

OUTPUT:

(2): REVERSAL OF SIGNAL


function[n]=sigfold(x,n)
y=fliplr(x);
n=-fliplr(n);
stem(n,y);

Afraz Khan (1616028)


11

end

OUTPUT:

(3): SINOSOIDAL SIGNAL


function[x,n]=sinuoseq(n1,n2)
n=[n1:0.1:n2];
x=cos(0.2*pi*n);
plot(n,x);
end

OUTPUT:

Afraz Khan (1616028)


12

EXPERIMENT-3
AIM: CONVOLUTION OF SIGNALS
function[y,ny]=conv_mod(x,nx,h,nh)
%[x,nx]=first signal
%[h,nh]=second signal
nyl=nx(1)+nh(1);
nyr=nx(length(x))+nh(length(h));
ny=[nyl:nyr];
y=conv(x,h);
stem(ny,y)
end

(1): x[n]: {3,11,7,0,-1,4,2} , n[x]={-3,3}


h[n]={2,3,0,-5,2,1} , n[h]={-1,4}

OUTPUT:
conv_mod([3 11 7 0 -1 4 2],[-3:3],[2 3 0 -5 2 1],[-1:4])
ans = 6 31 47 6 -51 -5 41 18 -22 -3 8 2

Afraz Khan (1616028)


13

60

40

20

-20

-40

-60
-4 -2 0 2 4 6 8

(2): x[n]={0.5,2} , n[x]={0,1}


h[n]={1,1,1} , n[h]={0,1,2}

OUTPUT:
conv_mod([0.5 2],[0:1],[1 1 1],[0:2])
ans = 0.5000 2.5000 2.5000 2.0000

2.5

1.5

0.5

0
0 0.5 1 1.5 2 2.5 3

(3): x[n]={-1,0.5,1,-0.5} , n[x]={-1,2}


h[n]={0.5,1,-.0.5,0.5} , n[h]={0,3}

OUTPUT:
conv_mod([-1 0.5 1 -0.5],[-1:2],[0.5 1 -0.5 0.5],[0:3])
ans = -0.5000 -0.7500 1.5000 0 -0.7500 0.7500 -0.2500

Afraz Khan (1616028)


14

1.5

0.5

-0.5

-1
-1 0 1 2 3 4 5

(4): x[n]={2,4,-2} , n[x]={0,2}


h[n]={1,0,5} , n[h]={0,1}

OUTPUT:
conv_mod([2 4 -2],[0:2],[1 0.5],[0:1])
ans = 2 5 0 -1

-1
0 0.5 1 1.5 2 2.5 3

(5): x[h]={2,-4,5,3,-1,-2,6} , n[x]={-3,3}


h[n]={1,-1,1,-1,-1} , n[h]={-1,3}

OUTPUT:
conv_mod([2 -4 5 3 -1 -2 6],[-3:3],[1 -1 1 -1 1],[-1:3])
ans = 2 -6 11 -8 7 -7 9 -4 7 -8 6

Afraz Khan (1616028)


15

12

10

-2

-4

-6

-8
-4 -3 -2 -1 0 1 2 3 4 5 6

(6): function[h,n]=diff2(b,a,n)
h=impz(b,a,n)
subplot(2,1,1);
stem(n,h)
title('Impulse response');
u=unitseq(0,-20,100);
s=filter(b,a,u)
subplot(2,1,2);
stem(n,s)
title('Step response');
end
OUTPUT:
diff2([1],[1 -1 0.9],[-20:100])

Afraz Khan (1616028)


16

Impulse response
1

0.5

-0.5

-1
-20 0 20 40 60 80 100

Step response
3

0
-20 0 20 40 60 80 100

(7): function[h,n]=diff2(b,a,n)
h=impz(b,a,n)
subplot(2,1,1);
stem(n,h)
title('Impulse response');

u=unitseq(0,-20,100);
s=filter(b,a,u)
subplot(2,1,2);
stem(n,s)
title('Step response');
stability_s=sum(abs(s))
stability_h=sum(abs(h))
end

OUTPUT:
diff2([1 2 1],[1 -0.5 0.25],[-20:100]
stability_s = 533.3333 stability_h = 6.5714

Afraz Khan (1616028)


17

(8): CONVOLUTION OF ONE FINITE AND INFINTE SIGNAL


function[h,n]=diff2(b,a,n)
u=unitseq(0,-20,100)-unitseq(10,-20,100);
s=filter(b,a,u)
stem(n,s)
title('Step response');
end

OUTPUT:

Step response
7

0
-20 0 20 40 60 80 100

(8):CONVOLUTION OF INTERCHAGE THE SIGNAL


function[h,n]=diff2(b,a,n)
u=unitseq(0,-10,100)-unitseq(5,-10,100);
s=filter(b,a,u)
stem(n,s)
title('Step response');
end

Afraz Khan (1616028)


18

OUTPUT:
Step response
2

1.8

1.6

1.4

1.2

0.8

0.6

0.4

0.2

0
-20 0 20 40 60 80 100

EXPERIMENT-4
AIM: SOLUTION OF DIFFERENCE EQUATION
(1): LOW PASS FILTER
>> STEP RESPONSE

OUTPUT:

Afraz Khan (1616028)


19

>> IMPULSE RESPONSE

OUTPUT:

(2): HIGH PASS FILTER


>> IMPULSE RESPONSE

OUTPUT:

Afraz Khan (1616028)


20

>> STEP RESPONSE

OUTPUT:

(3): LOW PASS FILTER WITH CUT OFF FREQUENCIES

>> FREQUENCY=5Hz
OUTPUT:

Afraz Khan (1616028)


21

>> FREQUENCY=100Hz
OUTPUT:

>>FREQUENCY=500Hz
OUTPUT:

(4): HIGH PASS FILTER WITH CUTOFF FREQUENCIES

Afraz Khan (1616028)


22

>>FREQUENCY=25Hz
OUTPUT:

EXPERIMENT-12
AIM: LAPLACE TRANSFORM OF CONTINUOUS TIME SIGNALS

(1): exp(t)u(t)
(2): 3exp(-2t)u(t)-2exp(-t)u(t)
(3): exp(-2t)u(t)+exp(-3t)u(t)
(4): exp(-2t)u(t)+exp(-t)cos(3t)u(t)
(5): d(t)-(4/3)exp(-t)u(t)+(1/3)exp(2t)u(t)

ANS:
(1): syms s t
L=laplace(exp(t)*heaviside(t))
OUTPUT:
L =1/(s - 1)

(2): syms s t
L=laplace(3*exp(-2*t)*heaviside(t)-2*exp(-1*t)*heaviside(t))
OUTPUT:
L =3/(s + 2) - 2/(s + 1)

(3): syms s t
L=laplace(exp(-2*t)*heaviside(t)+exp(-3*t)*heaviside(t))
OUTPUT:
L =1/(s + 2) + 1/(s + 3)

(4): syms s t
L=laplace(exp(-2*t)*heaviside(t)+exp(-1*t)*cos(3*t)*heaviside(t))
OUTPUT:
L =(s + 1)/((s + 1)^2 + 9) + 1/(s + 2)

(5): syms s t
L=laplace(dirac(t)-(4/3)*
exp(1*t)*heaviside(t)+(1/3)*exp(2*t)*heaviside(t))
OUTPUT:
L =1/(3*(s - 2)) - 4/(3*(s + 1)) + 1

Afraz Khan (1616028)


23

>>>>INVERSRE LAPLACE TRANSFORMATION


(1): (0.52s-0.31)/(s^2+0.685s+0.39)
(2): (5s+13)/(s(s^2+4s+13))
(3): (2s+13)/(s^2+4s+3)
(4): (s^2+2s+5)/((s+3)(s+5)^2)

ANSWERS--

(1): syms s
L=ilaplace((0.52*s-0.31)/(s^2+0.685s+0.39))
OUTPUT:
L=exp(-t) + exp(-3*t)

(2): syms s t
IL=ilaplace((5*s +13)/(s*(s^2+4*s+13)));
pretty(IL)
OUTPUT:
L=1 - exp(-2 t) (cos(3 t) - sin(3 t))

(3): syms s
L=ilaplace((2*s+13)/(s^2+4*s+3))
OUTPUT:
L = (11*exp(-t))/2 - (7*exp(-3*t))/2

(4): syms s
L=ilaplace((s^2+2*s+5)/((s+3)*(s+5)^2))
OUTPUT:
L =2*exp(-3*t) - exp(-5*t) - 10*t*exp(-5*t)

Afraz Khan (1616028)


24

EXPRIMENT-6
AIM: FOURIER SERIES REPRESENTATION OF CONTINUOUS TIME
SIGNAL

(1): syms t A T n;
w0=2*pi/T;
n=1:7
Bn=(2/T)*(int(A*(sin(n*w0*t)),t,0,T/2)+int(-A*(sin(n*w0*t)),t,T/2,T))
OUTPUT:
n= 1 2 3 4 5 6 7
Bn =[ (4*A)/pi, 0, (4*A)/(3*pi), 0, (4*A)/(5*pi), 0, (4*A)/(7*pi)]

(2) syms T n A ;
w0=2*pi/T;
n=1:7
A0=(2/T)*int(-A,t,-T/2,-T/4)+(2/T)*int(A,t,-T/4,T/4)+(2/T)*int(-A,t,T/4,T/2)
An=(2/T)*int(-A*(cos(n*w0*t)),t,-T/2,-T/4)+(2/T)*int(A*(cos(n*w0*t)),t
- T/4,T/4)+(2/T)*int(A*(cos(n*w0*t)),t,T/4,T/2)

OUTPUT:
A0 =0
An =[ (4*A)/pi, 0, -(4*A)/(3*pi), 0, (4*A)/(5*pi), 0, -(4*A)/(7*pi)]

>>>EVEN SIGNAL

Afraz Khan (1616028)


25

OUTPUT:

Afraz Khan (1616028)

You might also like