Labex2 2.4 2.8
Labex2 2.4 2.8
Labex2 2.4 2.8
% Program P2_4
clf;
n = 0:40;
D = 10;
a = 3.0;
b = -2;
x = a*cos(2*pi*0.1*n) + b*cos(2*pi*0.4*n);
xd = [zeros(1,D) x];
ic = [0 0];
y = filter(num,den,x,ic);
yd = filter(num,den,xd,ic);
d = y - yd(1+D:41+D);
subplot(3,1,1)
stem(n,y);
ylabel('Amplitude');
title('Output y[n]');
grid;
1
subplot(3,1,2)
stem(n,yd(1:41));
ylabel('Amplitude');
grid;
subplot(3,1,3)
stem(n,d);
ylabel('Amplitude');
title('Difference Signal');
grid;
Q2.12 The output sequences y[n] and yd[n-10] generated by running Program P2_4
are shown below –
2
These two sequences are related as follows - y[n] = yd[n-10]
Q2.13 The output sequences y[n] and yd[n-D] generated by running Program P2_4 for
the following values of the delay variable D – 30
3
In each case, these two sequences are related as follows -
The system is -
1. Q2.14 The output sequences y[n] and yd[n-10] generated by
running Program P2_4 for the following values of the input frequencies -
1.f1=0.05; f2=0.40;
2. f1=0.10; f2=0.25;
3. f1=0.15; f2=0.20;
4
5
In each case, these two sequences are related as follows - y[n] = yd[n-
10]
Q2.15 The output sequences y[n] and yd[n-10] generated by running Program P2_4
for non-zero initial conditions are shown below -
6
These two sequences are related as follows - y[n] ≠ yd[n-10]
1. f1=0.05; f2=0.40;
7
In each case, these two sequences are related as follows - y[n] ≠
yd[n-10]
is given below:
% Program Q2_17
clf;
n = 0:40;
D = 10;
a = 3.0;
b = -2;
8
x = a*cos(2*pi*0.1*n) + b*cos(2*pi*0.4*n);
xd = [zeros(1,D) x];
nd = 0:length(xd)-1;
y = (n .* x) + [0 x(1:40)];
d = y - yd(1+D:41+D);
subplot(3,1,1)
stem(n,y);
ylabel('Amplitude');
title('Output y[n]');
grid;
subplot(3,1,2)
stem(n,yd(1:41));
ylabel('Amplitude');
grid;
subplot(3,1,3)
stem(n,d);
ylabel('Amplitude');
title('Difference Signal');
grid;
>>
9
These two sequences are related as follows – y[n] ≠ yd[n-10]
Q2.18 (optional) The modified Program P2_3 to test the linearity of the system of Q2.18 is
shown below:
clf;
n = 0:40;
a = 2;
b = -3;
x1 = cos(2*pi*0.1*n);
x2 = cos(2*pi*0.4*n);
x = a*x1 + b*x2;
10
y1 = (n .* x1) + [0 x1(1:40)];
y2 = (n .* x2) + [0 x2(1:40)];
y = (n .* x) + [0 x(1:40)];
yt = a*y1 + b*y2;
d = y - yt;
subplot(3,1,1)
stem(n,y);
ylabel('Amplitude');
subplot(3,1,2)
stem(n,yt);
ylabel('Amplitude');
subplot(3,1,3)
stem(n,d);
ylabel('Amplitude');
title('Difference Signal');
>>
The outputs y[n]and yt[n] obtained by running the modified program P2_3 are
shown below:
11
The two sequences are -
The system is -
12
Answers:
Q2.30 The purpose of the for command is Để lặp lại một nhóm các câu lệnh Matlab một
số lần nhất định, bạn có thể sử dụng vòng lặp "for" hoặc "while". Lệnh "end" sẽ đánh
Q2.31 The purpose of the break command is - để chấm dứt việc thực hiện "for" hoặc
Vòng lặp "while".
13
The value of |h(K)| here is - 1.6761e-005
From this value and the shape of the impulse response we can conclude that the
system is - ổn định
By running Program P2_8 with a larger value of N the new value of | h(K)|
is - 9.1752e-007
Q2.33 The modified Program P2_8 to simulate the discrete-time system of Q2.33 is given
below:
clf;
N = 200;
h = impz(num,den,N+1);
parsum = 0;
for k = 1:N+1;
end
n = 0:N;
stem(n,h)
ylabel(’Amplitude’);
disp(’Value =’);
disp(abs(h(k)));
14
The impulse response generated by running the modified Program P2_8 is shown
below:
The values of |h(K)| here are - 2.0321
From this value and the shape of the impulse response we can conclude that the
system is – không ổn định
15