Professional Documents
Culture Documents
SCHOOL OF ENGINEERING
DEPARTMENT OF ELECTRONICS
AND ELECTRICAL
ENGINEERING
Submitted by:
Submitted to:
Write MATLAB code to generate and plot the given signal. Scale your time axis so that a sufficient
amount
of the signal is being plotted. Use subplot if required,Ms.
labelSmriti
your plots
witht on the x-axis for the
Bishesh
Acharya
Nakarmi
continuous time signals and nfor discrete time signals. The y-axis should be labeled x (t) or x[n]: the
Roll no. 31001
Department
title should also be included with problem
number.of Electrical and
Electronics Engineering
1. Generate unit step signal.
Group : EE(communication)
t=-10:0.2:10;
u=(t>=0);
plot(t,u);
grid;
xlabel('t');
ylabel('x(t)');
title('unit step signal');
2. Generate and plot unit sample sequence in both continuous time and discrete time.
-
t=-10:0.1:10;
a=(t>=0);
subplot(2,1,1);
plot(t,a);
grid;
xlabel('t');
ylabel('u(t)');
title('unit step continuous time signal');
n=-10:0.5:10;
b=(n>=0);
subplot(2,1,2);
stem(n,b);
grid;
xlabel('n');
ylabel('u(n)');
title('unit step discrete time signal');
u n it s t e p c o n t i n u o u s t im e s ig n a l
1
0 .8
u(t)
0 .6
0 .4
0 .2
0
-1 0
-8
-6
-4
-2
0
t
10
10
u n it s t e p d is c re te t im e s ig n a l
1
0 .8
u(n)
0 .6
0 .4
0 .2
0
-1 0
-8
-6
-4
-2
0
n
n=0:40;
c=2;
x=c*exp((-1/12)+(pi/6)*i).*n;
stem(n,x);
xlabel('n');
ylabel('x(n)');
title('complex exponential signal');
60
50
x(n)
40
30
20
10
0
0
10
b. x[n]=.5(1.5n)
n=0:30;
c=0.5
x=c*(1.5).^n;
plot(n,x);
grid;
xlabel('n');
ylabel('x(n)');
title('real exponential system');
15
20
n
25
30
35
40
10
x 10
9
8
7
x(n)
6
5
4
3
2
1
0
10
c. x(t)=ei(t+1)
-
t=0:9;
c=1;
x=c*exp(i*(pi*t+1));
plot(t,real(x));
hold on
plot(t,imag(x),'r');
xlabel('t');
ylabel('x(t)');
title('complex exponential signal');
15
n
20
25
30
co
m
p
le
xe
x
p
o
n
e
n
tia
ls
ig
n
a
l
1
0
.8
0
.6
0
.4
x(t)
0
.2
-0
.2
-0
.4
-0
.6
-0
.8
-1
n=0:0.001:30;
x=2*cos((pi*n)/6)+sin((pi*n)/8)-2*cos((pi*n)/2+(pi*n)/6);
plot(n,x);
xlabel('n');
ylabel('x(n)');
title('sinusoidal signal');
sinusoidal signal
4
3
2
1
x(n)
0
-1
-2
-3
-4
-5
5. Plot
a. y[n]=1/3(x[n-1]+x[n]+x[n+1])
n=-40:0.01:40;
x=cos((pi/3)*n);
subplot(4,1,1);
plot(n,x);
x1=cos((pi/3)*(n-1));
subplot(4,1,2);
plot(n,x1);
x2=cos((pi/3)*(n+1));
subplot(4,1,3);
plot(n,x2);
y=(1/3)*(x+x1+x2);
subplot(4,1,4);
plot(n,y);
xlabel('n');
ylabel('y(n)');
10
15
n
20
25
30
1
0
-1
-40
1
-30
-20
-10
10
20
30
40
-30
-20
-10
10
20
30
40
-30
-20
-10
10
20
30
40
-30
-20
-10
0
n
10
20
30
40
0
-1
-40
1
0
y(n)
-1
-40
1
0
-1
-40
b. y[n]=(1/2)nu[n-3]
n=-10:0.01:10;
u=((n-3)>=0);
y=((1/2).^n).*u;
plot(n,y);
xlabel('n');
ylabel('y(n)');
0.14
0.12
0.1
y(n)
0.08
0.06
0.04
0.02
0
-10
-8
-6
-4
-2
0
n
10
c. y[n]=e(i4n)/7-e(i2n/5)
n=-10:0.5:10;
y=exp(((i*4*pi)).*n)/7-exp(((i*pi*2).*n)/5);
plot(n,real(y));
hold on
plot(n,imag(y),'r');
xlabel('n');
ylabel('y(n)');
1.5
0.5
y(n)
-0.5
-1
-10
-8
-6
-4
-2
0
n
10
t=-1:0.001:1;
x=4*cos((5*pi).*t-(pi/4));
plot(t,x);
xlabel('t');
ylabel('x(t)');
4
3
2
x(t)
1
0
-1
-2
-3
-4
-1
b. x[n]=4cos(n)
n=-5:0.001:5;
x=4*cos(pi.*n);
plot(n,x);
xlabel('n');
ylabel('x(n)');
-0.8
-0.6
-0.4
-0.2
0
t
0.2
0.4
0.6
0.8
4
3
2
x(n)
1
0
-1
-2
-3
-4
-5
-4
-3
-2
-1
0
n
c. x[n]= 2sin(3n)
n=-4:0.001:4;
x=2*sin(3.*n);
plot(n,x);
xlabel('n');
ylabel('x(n)');
2
1.5
1
0.5
x(n)
0
-0.5
-1
-1.5
-2
-4
-3
-2
-1
0
n
d. x(t)=cos(4t)+2sin(8t)
t=-1:0.001:1;
x=cos(4.*t)+2*sin(8.*t);
plot(t,x);
xlabel('t');
ylabel('x(t)');
x(t)
-1
-2
-3
-1
-0.8
e. x(t)=3cos(4t)+sin(t)
t=-2:0.001:2;
x=3*cos(4.*t)+sin(pi.*t);
plot(t,x);
xlabel('t');
ylabel('x(t)');
-0.6
-0.4
-0.2
0
t
0.2
0.4
0.6
0.8
4
3
2
x(t)
1
0
-1
-2
-3
-4
-2
-1.5
-1
-0.5
0
t
0.5
1.5