Professional Documents
Culture Documents
DC LAB Report#01&02
DC LAB Report#01&02
Subject:
Digital Communications
Title:
Intro to Matlab
SUBMITED by:
Zueem-Ul-Haq
20380
SUBMITED TO:
Sir. Ahmad
Date:
23 May 2017
Lab Report 9
Digital Communication
Lab Title
AWGN noise, Entropy
Submitted to:
Sir Ahmed
Submitted by:
Hammad Hafeez
ID:
20294
TASK-1:
X=0:0.1:6;
Y=sin(X);
plot(X,Y);
OUTPUT
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 1 2 3 4 5 6
TASK-2:
X=0:0.1:6;
Y=sin(X);
plot(X,Y);
Output
16
14
12
10
2
0 1 2 3 4 5 6 7 8 9 10
TASK-3:
u=1;
v=3;
a=(4*u/3*v)
b=2*v.^-2/(u+v).^2
c=v.^3/v.^3-u^3
d=4/3*pi*v.^2
Output
a= 4
b =0.0139
c=0
d = 37.6991
TASK-4:
a=zeros(6)
b=zeros(6,1)
c=zeros(3,4)
Output
a =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
b = 0
0
0
0
0
c = 0 0 0 0
0 0 0 0
0 0 0 0
TASK-5:
a=[1.1 0.0 2.1 -3.5 6.0; 0.0 1.1 -6.6 2.8 3.4; 1.1 0.1 0.3 -0.4 1.3; -1.4 5.1
0.0 1.1 0.0]
siz1=size(a)
vale1=a(4,1)
siz2=size(a(:,1:2))
siz3=size(a([1 3],end))
Output
a=
siz1 =4 5
vale1 = -1.4000
size2 = 4 2
size3 = 2 1
TASK-6:
dog1 LEGALL
1dog ILLEGAL
Do_you_know_the_way__to_lahore LEGALL
_help ILLEGAL
TASK-7:
a=1:2:5
b=[a' a' a']
c=b(1:2:3,1:2:3)
d=a+b(2,:);
w=[zeros(1,3) ones(3,1)' 3:5']
b([1 3],2 )=b([3 1],2)
size_a=size(a)
size_b=size(b)
size_c=size(c)
size_d=size(d)
Output
a=1 3 5
b=
1 1 1
3 3 3
5 5 5
c=
1 1
5 5
w= 0 0 0 1 1 1 3 4 5
b=
1 5 1
3 3 3
5 1 5
siz_a = 1 3
size_b =3 3
size_c = 2 2
size_d =1 3
TASK-8:
a=[1.1 0.0 2.1 3.5 6.0;0.0 1.1 6.6 2.8 3.4;2.1 0.1 0.3 0.4 1.3;1.4 5.1 0.0
1.1 0.0]
a(3,:)
a(:,3)
a(1:2:3,[3 3 4])
a([1 1],:)
Output
a=
ans =
2.1000
6.6000
0.3000
ans =
ans =
disp('normal')
elseif(30<temp && temp<=100)
disp('very hot')
elseif(temp<100)
disp('very hot')
end
Output
Enter temp=77
temp = 77
very hot
TASK-10:
for i=1:10
if(i>5)
b(i)=1
else
b(i)=0
end
end
TASK-11(A):
x=[-1:3]
y=x.^2
b=y-3*x+2
plot(b
Output
6
0
1 1.5 2 2.5 3 3.5 4 4.5 5
TASK-11(B):
a=input('input the value=')
b=1
for i=1:a;
b=b*i:
end
disp(b)
Output
input the value=5
a =5
b =120
TASK-11(C):
n=-2:0.5:2
x=zeros(1,9)
x(1,5)=1
stem(n,x)
title('unit impulse function')
xlabel('time')
ylabel('amplitude')
Output
unit impulse function
1
0.9
0.8
0.7
0.6
amplitude
0.5
0.4
0.3
0.2
0.1
0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
time
TASK-11(D):
n=-1:10;
n0=3
x=[(n-n0)>=1]
stem(n,x);
title('unit step function')
xlabel('time')
ylabel('amplitude')
Output
unit step function
1
0.9
0.8
0.7
0.6
amplitude
0.5
0.4
0.3
0.2
0.1
0
-2 0 2 4 6 8 10
time
TASK-11(E):
x=input(‘Enter the Matrix=);
y=length(x)
k=0;
p=0;
for i=1:y/2
if(x(i)==x(y))
k=1;
elseif(x(i)==-x(y))
p=1;
end
y=y-1;
end
if(k==1)
disp(‘Even’)
elseif(p==1)
disp(‘Odd’)
end
Output
Enter the Matrix=[2 1 0 1 2]
Even