Labex2 2.4 2.8

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 15

Project 2.

4 Time-invariant and Time-varying Systems

A copy of Program P2_4 is given below:

% Program P2_4

% Generate the input sequences

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];

num = [2.2403 2.4908 2.2403];

den = [1 -0.4 0.75];

ic = [0 0];

% Set initial conditions

% Compute the output y[n]

y = filter(num,den,x,ic);

% Compute the output yd[n]

yd = filter(num,den,xd,ic);

% Compute the difference output d[n]

d = y - yd(1+D:41+D);

% Plot the outputs

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');

title(['Output due to Delayed Input x[n Ð', num2str(D),']']);

grid;

subplot(3,1,3)

stem(n,d);

xlabel('Time index n');

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]

The system is – hàm thời gian bất biến

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

are shown below – thời gian bất biến

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;

are shown below –

4
5
In each case, these two sequences are related as follows - y[n] = yd[n-
10]

The system is – Thời gian bất biến

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]

The system is – Thời gian biến thiên


Q2.16 The output sequences y[n] and yd[n-10] generated by running
Program P2_4 for non-zero initial conditions and following values of the
input frequencies
– ic = [2 10]

1. f1=0.05; f2=0.40;

are shown below -

7
In each case, these two sequences are related as follows - y[n] ≠
yd[n-10]

The system is – Thời gian biến thiên

Q2.17 The modified Program 2_4 simulating the system

y[n] = n x[n] + x[n-1]

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)];

yd = (nd .* xd) + [0 xd(1:length(xd)-1)];

d = y - yd(1+D:41+D);

% Plot the outputs

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');

title(['Output due to Delayed Input x[n -', num2str(D),']']);

grid;

subplot(3,1,3)

stem(n,d);

xlabel('Time index n');

ylabel('Amplitude');

title('Difference Signal');

grid;

>>

The output sequences y[n] and yd[n-10] generated by running modified


Program P2_4 are shown below –

9
These two sequences are related as follows – y[n] ≠ yd[n-10]

The system is -hệ thống biến thiên

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');

title('Output Due to Weighted Input: a \cdot x_{1}[n] + b \cdot x_{2}[n]');

subplot(3,1,2)

stem(n,yt);

ylabel('Amplitude');

title('Weighted Output: a \cdot y_{1}[n] + b \cdot y_{2}[n]');

subplot(3,1,3)

stem(n,d);

xlabel('Time index n');

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 -

Project 2.8 Stability of LTI Systems

A copy of Program P2_8 is given below:


% Program P2_8
% Stability test based on the sum of the absolute % values of the
impulse response samples
clf;
num = [1 -0.8]; den = [1 1.5 0.9];
N = 200;
h impz(num,den,N+1);
parsum = 0;
for k = 1:N+1; parsum = parsum + abs(h(k));
if abs(h(k)) < 10^(-6), break, end
end
% Plot the impulse response
n = 0:N;
stem(n,h) xlabel(’Time index n’);
ylabel(’Amplitude’);
% Print the value of abs(h(k)) disp(’Value =’);disp(abs(h(k)));

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

dấu kết thúc của nhóm câu lệnh này.


The purpose of the end command is - Để đánh dấu sự kết thúc của khối các câu

lệnh sẽ được lặp lại, Matlab sử dụng lệnh `end`.

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".

Q2.32 The discrete-time system of Program P2_8 is - y[n] + 1.5y[n-1] +


0.9y[n-2] = x[n] –
0.8x[n-1]

The impulse response generated by running Program P2_8 is shown below :

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

From this value we can conclude that the system is - ổn định

Q2.33 The modified Program P2_8 to simulate the discrete-time system of Q2.33 is given
below:

clf;

num = [1 -4 3]; den = [1 -1.7 1.0];

N = 200;

h = impz(num,den,N+1);

parsum = 0;

for k = 1:N+1;

parsum = parsum + abs(h(k));

if abs(h(k)) < 10^(-6), break, end

end

% Plot the impulse response

n = 0:N;

stem(n,h)

xlabel(’Time index n’);

ylabel(’Amplitude’);

disp(’Value =’);

disp(abs(h(k)));

xlabel(’Time index n’);

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

You might also like