You are on page 1of 10

LAB REPORT 1

HW SOLUTION:01
HW:1.02

clc
clear all;
close all;
T=0.001;
t1=0:0.0001:T;
xa=sin(1000*pi*t1);
subplot(3,2,1)
plot(t1,xa)
Fs=10000;
Ts=1/Fs;
N1=round(T/Ts);
n1=0:N1-1;
x1=sin(1000*pi*n1*Ts);
subplot(3,2,2)
stem(n1,x1);
T=0.001;
t2=0:0.0001:T;
xb=sin(1000*pi*t2);
subplot(3,2,3)
plot(t2,xb)
Fs=1000;
Ts=1/Fs;
N2=round(T/Ts);
n2=0:N2-1;
x2=sin(1000*pi*n2*Ts);
subplot(3,2,4);
stem(n2,x2)
T=0.001;
t3=0:0.0001:T;
xc=sin(1000*pi*t3);
subplot(3,2,5);
plot(t3,xc);
Fs=100000;
Ts=1/Fs;
N3=round(T/Ts);
n3=0:N3-1;
x3=sin(1000*pi*n3*Ts);
subplot(3,2,6);
stem(n3,x3)
1 1

0.5 0.5

0 0
0 0.5 1 0 5 10
-3
x 10
1 1

0.5 0

0 -1
0 0.5 1 -1 -0.5 0 0.5 1
-3
x 10
1 1

0.5 0.5

0 0
0 0.5 1 0 50 100
-3
x 10

HW:1.01

clear all;
close all;
%%parameter file:
Ts=1/8000;
b=4;
T=0.01;
F=100;
%% ADC:
%Generation of analog signal:
t=-5:0.1:5;
xa=4.5*sin(2*pi*100*t);
% sampling
N1=round(T/Ts);
n1=0:N1-1;
x1=4.5*sin(2*pi*100*t);
% Quantization:
L=2^b;
y1=uquant(x1,L);
%%DAC:
xa1=zeros(1,length(t));
for i=1:length(y1)
g=sinc((t-(i-1)*Ts)/Ts);
xa1=xa1+y1(i)*g;
end
%%plots:
figure
plot(t,xa)
hold on
plot(t,xa1,'r')
ylabel('signal level');
legend('original signal', 'reconstructed signal')
title('ADC and DAC operation');

-12
x 10 ADC and DAC operation
2.5
original signal
2 reconstructed signal

1.5

0.5
signal level

-0.5

-1

-1.5

-2

-2.5
-5 -4 -3 -2 -1 0 1 2 3 4 5

LAB REPORT 2
HW:1
clc
clear all
close all
x=[1,-2,6,-5,4,6,8,10];
n=-4:3;
subplot(2,1,1);
stem(n,x);
[xa,na]=sigshift(x,n,-2);
[xb,nb]=sigshift(x,n,4);
[xc,nc]=sigshift(x,n,0);
[xy,ny]=sigadd(3*xa,na,xb,nb);
[x1,n1]=sigadd(xy,ny,-2*xc,nc);
subplot(2,1,2);
stem(n1,x1);

10

-5
-4 -3 -2 -1 0 1 2 3

40

20

-20

-40
-6 -4 -2 0 2 4 6 8
HW 2.a

function[x,n]=ramp(n0,n1,n2)
n=[n1:n2];
x=n0.^n;
end

Hw 2.b

clc
clear all
close all
n=-10:10.3;
r=ramp(1.1,-10,10.3);
stem(n,r);

2.5

1.5

0.5

0
-10 -8 -6 -4 -2 0 2 4 6 8 10

Hw 3

% (a)
clear all
close all
clc
n1=-30;
n2=30;
n=n1:n2;
x=5*u(0,-30,30)-5*u(20,-30,30);
figure
stem(n,x);
title('sequence in problem a')
sequence in problem a
5

4.5

3.5

2.5

1.5

0.5

0
-30 -20 -10 0 10 20 30

LAB REPORT 3

HW:1

clc
clear all
close all
%a
T=10;
t=0:0.001:T;
xa=sin(20*pi*t);
Fs=40;
Ts=1/Fs;
N1=round(T/Ts);
n1=0:N1-1;
x1=sin(20*pi*n1*Ts);
subplot(3,1,1);
stem(n1,x1)
%b
noise=rand(1,length(x1));
x_noisy=x1+noise;
subplot(3,1,2);
stem(n1,x_noisy);
ylabel('b');
%c
M=200;
a=1;
b1=[n1<=M];
b1=b1/M;
H1=filter(b1,a,x1);
[y1,w1]=freqz(H1,128);
figure(1)
subplot(3,1,1)
plot(n1,H1)
subplot(3,1,2)
plot(w1/pi),abs(y1))
subplot(3,1,3)
plot((w1/pi),angle(y1))

0.01

-0.01
0 50 100 150 200 250 300 350 400
2

1
b

-1
0 50 100 150 200 250 300 350 400

Hw 2a.

clc
clear all
close all
n=-25:25;
x=u(0,-25,25)-u(20,-25,25);
a=[1];
b=[0.05*20];
y=filter(b,a,x);
figure
subplot(2,1,1);
stem(n,x);
ylabel('x');
subplot(2,1,2);
stem(n,y);
ylabel('y');

0.8

0.6
x

0.4

0.2

0
-25 -20 -15 -10 -5 0 5 10 15 20 25

0.8

0.6
y

0.4

0.2

0
-25 -20 -15 -10 -5 0 5 10 15 20 25

HW:2b

clc
clear all;
close all;
a=[1,-1];
b=[1];
n=-25:25;
x=u(0,-25,25)-u(10,-25,25);
y=filter(b,a,x);
figure
subplot(2,1,1);
stem(n,x);
ylabel('x');
subplot(2,1,2);
stem(n,y);
ylabel('y');
1

0.8

0.6
x

0.4

0.2

0
-25 -20 -15 -10 -5 0 5 10 15 20 25

10

6
y

0
-25 -20 -15 -10 -5 0 5 10 15 20 25

HW:2c

clc
clear all
close all
n=-25:25;
a=[1,-1];
b=[1];
h=filter(b,a,delta(0,-25,25));
figure
stem(n,h);
sum_imp=sum(abs(h))

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
-25 -20 -15 -10 -5 0 5 10 15 20 25

You might also like