Академический Документы
Профессиональный Документы
Культура Документы
Table of Contents
1(a)
1(b)
1(c)
1(d)
2(a)
2(b)
3(a)
4(a)
4(b)
5(a)
5(b)
5(c)
5(d)
6(a)
6(b)
7(a)
7(b)
7(c)
................................................................................................................................... 1
................................................................................................................................... 2
................................................................................................................................... 3
................................................................................................................................... 4
................................................................................................................................... 5
................................................................................................................................... 6
................................................................................................................................... 7
................................................................................................................................... 7
................................................................................................................................... 8
................................................................................................................................... 9
................................................................................................................................. 10
................................................................................................................................. 12
................................................................................................................................. 12
................................................................................................................................. 14
................................................................................................................................. 15
................................................................................................................................. 16
................................................................................................................................. 17
................................................................................................................................. 18
1(a)
impulse = [zeros(1,10) 1 zeros(1,9)];
n = -10:9;
stem(n,impulse)
xlabel('n')
%or we can do this
n = -10:9;
x = 0*n;
index=find(n==0);
x(index)=1;
stem(n, x);
axis([-inf, inf, -0.2, 1.2]);
xlabel('n'); ylabel('x');
title('Delayed Unit Impulse Signal \delta[n-k]');
1(b)
unitStep = [zeros(1,10) 1 ones(1,9)];
n = -10:9;
stem(n,unitStep)
xlabel('n')
ylabel('Unit Step')
% or we can do like this
n = -10:9;
x = 0*n;
index=find(n>=0);
x(index)=1;
stem(n, x)
axis([-inf, inf, -0.2, 1.2]);
xlabel('n');
ylabel('x');
title('Unit Step Signal u[n]');
1(c)
figure
y = linspace(0,2*pi,50);
x = y;
stem(x,y)
xlabel('n')
ylabel('Ramp Function')
1(d)
a^0.9
n = -10:10;
x = 0.9.^n;
stem(n,x)
title('Exponential Signal a^n')
xlabel('n')
ylabel('Output')
2(a)
n = -10:10;
x = 3*sin(2*pi*n + pi/3);
stem(n,x)
xlabel('n')
ylabel('Output')
2(b)
n = -10:10;
x = 5*cos(2*pi*n/3 + pi/4) + 2.5*sin(pi*n/3 + pi/4);
stem(n,x)
xlabel('n')
ylabel('Output')
3(a)
x = 0;
a = 0.9;
for n = 0:100
x = x + a^n;
end
disp('Final value of a:')
x
Final value of a:
x =
9.9998
4(a)
r = 0.8;
n = 0:20;
sig = (r.^n).*exp(i*pi*n/3);
realSig = real(sig);
subplot(1,2,1)
stem(n,realSig)
title('Real')
xlabel('n')
ylabel('Real Part')
imgSig = imag(sig);
subplot(1,2,2)
stem(n, imgSig)
title('Imaginary')
xlabel('n')
ylabel('Imaginary Part')
4(b)
absol = abs(sig);
subplot(1,2,1)
stem(n,absol)
title('Absolute')
xlabel('n')
ylabel('Magnitude')
ang = angle(sig);
subplot(1,2,2)
stem(n, ang)
title('Angle')
xlabel('n')
ylabel('Phase')
5(a)
n = -10:20;
unit = [zeros(1,10) 1 zeros(1,20)];
figure
stem(n, unit)
title('Unit sampel Signal')
xlabel('n')
ylabel('Output')
5(b)
[y,n] = sigshift(unit,n,11);
figure
stem(n,y)
title('Unit sampel signal with delay of 11')
xlabel('n')
ylabel('Output')
% or
n1 = 10; n2 = 20
n = -n1:n2;
delay = 11;
unit = [zeros(1,n1+delay) 1 zeros(1,n2-delay)];
figure
stem(n, unit)
title('Unit sampel signal with delay of 11')
xlabel('n')
ylabel('Output')
n2 =
20
10
11
5(c)
n = -10:20;
unit = [zeros(1,10) ones(1,21)];
figure
stem(n, unit)
title('Unit step function')
xlabel('n')
ylabel('Output')
5(d)
[y,n] = sigadv(unit,n,7);
figure
stem(n,y)
title('Unit step function with advancement of 7 sample')
xlabel('n')
ylabel('Output')
% or we can do like this
n1 = 10; n2 = 20;
n = -n1:n2;
unit = [zeros(1,n1-7) ones(1,n2+8)];
figure
stem(n, unit)
title('Unit step function with advancement of 7 sample')
12
xlabel('n')
ylabel('Output')
13
6(a)
n = linspace(-2*pi,2*pi,50);
freq = 0.08;
amp = 2.5;
theta = pi/2;
f = amp*sin(2*pi*freq*n + theta);
figure
stem(n, f)
xlabel('n')
ylabel('Output')
14
6(b)
n = linspace(-2*pi,2*pi,100);
fs = 8000;
x = 5*cos(2*pi*(500/fs)*n) + 5*cos(2*pi*(1200/fs)*n);
subplot(1,2,1)
stem(n,x)
title('Sampled Signal')
xlabel('n')
ylabel('Output')
subplot(1,2,2);
plot(n,x)
title('Continoues Signal')
xlabel('n')
ylabel('Output')
15
7(a)
a = -2; b = 2;
n = 1:100;
r = rand(100,1);
f = a + (b-a).*r;
figure
stem(n,f)
disp('Histogram of the function')
hist(f)
Histogram of the function
16
7(b)
mean = 0;
varience = 3;
sd = sqrt(varience);
n = 1:75;
b = randn(75,1);
r = mean + sd.*b;
subplot(1,2,1)
stem(n,r)
subplot(1,2,2)
disp('Histogram of the Function')
hist(r)
Histogram of the Function
17
7(c)
for sample = 1:5
n = -2 + 4.*rand(31,1);
f = 0.1;
x =[];
A = 4.*rand(31,1);
theta = 0 + (2*pi-0).*rand(31,1);
for i = 1:31
x(i,:) = A(i,:)*cos((2*pi*f)*n(i,:) + theta(i,:));
end
subplot(3,2,sample)
stem(n,x)
title('Sample')
end
18
19