Tải bản đầy đủ (.pdf) (29 trang)

Báo Cáo Tín Hiệu Và Hệ Thống

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.61 MB, 29 trang )

ĐẠI HỌC BÁCH KHOA – ĐẠI HỌC ĐÀ NẴNG
KHOA ĐIỆN TỬ - VIỄN THƠNG
----------






















BÁO CÁO
THÍ NGHIỆM TÍN HIỆU VÀ HỆ THỐNG







NHÓM 20.39
Giảng viên hướng dẫn: ThS. Trần Văn Líc

Sinh viên thực hiê ̣n

:

Lớp sinh hoa ̣t

:

Mã số sinh viên

Đà Nẵng, năm 2022

1


MỤC LỤC
Lab 1 : Introduction to Matlab
Practice myself
Lab 2 : Some Fundamental Propertiles of Signals ..............................................3
1. Consider the discrete-time signal ..................................................................3
2) Now consider the following signals ...............................................................4
3) a) Define a MATLAB vector nx to be the time indices - 3 ≤ n ≤ 7 and the
MATLAB vector x to be the values of the signal x[n] is given by ....................5
b) For this part, you will define MATLAB vectors y1 through y4 to represent
the following discrete-time signals ....................................................................6

Lab 3 : Some Fundamental Properties of Systems ..............................................8
1. Linearity ............................................................................................................8
Exercise 1 .........................................................................................................8
2. Causality .........................................................................................................9
Exercise 2 .........................................................................................................9
3. Stability ........................................................................................................10
4. Invertible and Inverse ..................................................................................11
Exercise 4 .......................................................................................................11
Lab 4 : The Convolution Sum and Integral .......................................................13
Exercise 1 .......................................................................................................13
Exercise 2 .......................................................................................................14
II. Repeat part I using u[n+5] instead of u[n] ................................................14
Exercise 3 .......................................................................................................15
LAB 5 : Differental Equations ...........................................................................17
1. LTI Systems Described by Differential Equations .....................................17
Exercise 1 .......................................................................................................17
Exercise 2 .......................................................................................................18
Exercise 3 .......................................................................................................19
LAB 6 : Fourier Series and Fourier Transform Representation
.............................................................................................................................21
6.1 Compute the DTFS with fft: ......................................................................21
Exercise 1 .......................................................................................................21

2


LAB 1 : INTRODUCTION TO MATLAB
Practice myself
LAB 2 : SOME FUNDAMENTAL PROPERTIES OF SIGNALS
1.Consider the discrete-time signal


and assume N=12. For M=4, 5, 7 and 10, plot xM [n] on the interval 0 ≤ n ≤ 2N -1.
Use stem to create your plots, and be sure to appropriately label your axes. What is the
fundamental period of each signal?
Trả Lời:
%Nguyen Van Vinh Hoa code
%Eg1
N=12;
n=[0:2*N-1];
M=4
x_M=sin((2*pi*M*n)/N);
figure(1)
stem(n,x_M,'filled')
title('x[n]=sin(2*pi*M*n/N)')
xlabel('Time')
ylabel('Amplitude')

Thay lần lượt M= 5,7,10 ta được các kết quả như sau:

M=4

M=5

3


M=7

M=10


2) Now consider the following signals:

Assume N=6 for each signal. Determine whether or not each signal periodic. If a
signal is periodic, plot the signal for two periods, starting at n=0. Plot the signal
for 0 ≤ n ≤7N and
explain why it is periodic or not. Remember to use stem and to appropriately label
your axes.
Trả lời:
%Nguyen Van Vinh Hoa code
%Eg2
N=6;
n=[0:7*N];
x2=2*cos(2*n/N)+cos(3*n/N);
x3=cos(2*pi*n/N)+3*sin(5*(pi/2)*n/N);
figure (5)
subplot(2,1,1),stem(n,x2)
title('x2[n]')
subplot(2,1,2),stem(n,x3)
title('x3[n]')

Kết quả :

4


5


3) a) Define a MATLAB vector nx to be the time indices - 3 ≤ n ≤ 7 and the
MATLAB vector x to be the values of the signal x[n] is given by


If you have defined these vectors correctly, you should be able to plot this discrete
time sequence by typing stem (nx,x).
Trả lời:
%Nguyen Van Vinh Hoa code
nx=[-3:7];
x=[0 0 0 2 0 1 -1 3 0 0 0];
figure (8)
stem(nx,x,'filled')
title('x[n]')
xlabel('n')
ylabel('x[n]')

Kết quả :

6


b) For this part, you will define MATLAB vectors y1 through y4 to represent
the following discrete-time signals:

to do this, you should define y1 through y4 to be equal to x. The key is to define
correctly the corresponding index vectors ny1 through ny4. First, you should figure
out how the index of a given sample of x[n] changes when transforming to yi[ ] n .
The index vectors need not span the same of indices as nx, but they should all be at
least 11samples long and include the indices of all nonzero samples of associated
signal.
Trả lời:
%Nguyen Van Vinh Hoa code
%Eg3

n=[-3:7];
x=[2 0 1 -1 3 0];
nx=[0 0 0 x 0 0];
ny1=n+2;
ny2=n-1;
ny3=-n;
ny4=-n+1;
figure(6)
subplot(2,1,1),stem(ny1,nx,'filled')
xlabel('time')
ylabel('x[n-2]')
title('x[n-2]')
subplot(2,1,2),stem(ny2,nx,'filled')
xlabel('time')
ylabel('x[n+1]')
title('x[n+1]')
figure(7)
subplot(2,1,1),stem(ny3,nx,'filled')
xlabel('time')
ylabel('x[-n]')
title('x[-n]')
subplot(2,1,2),stem(ny4,nx,'filled')
xlabel('time')
ylabel('x[-n+1]')
title('x[-n+1]')

Kết quả :

7



8


9


LAB 3 : SOME FUNDAMENTAL PROPERTIES OF SYSTEMS
1. Linearity:
Exercise 1
The system
is not linear. Show that it violates linearity by giving a counter
example. Agood example is the set of signals

Write a MATLAB code to demonstrate this example. This can be done as follows:
- Define the domain of the two signals to be from -3 to 3 and save it as a vector n
- Define the signal x1 as a vector of the values [0 0 0 1 0 0 0]
- Define the signal x2 =2x1
- Evaluate the output corresponding to the x1 input, and label it as y1
- Evaluate the output corresponding to the x2 input, and label it as y2
On the same graph window, plot the signals x1, x2, y1 and y2 using the commands
(subplot) and (stem). Your results should be as depicted in Figure 1.
Trả lời :
%Nguyen Van Vinh Hoa code
%LAB3
%Exercise 1
n=[-3:3];
x1 = [0 0 0 1 0 0 0];
x2 = 2*x1;
y1=sin(pi/2*x1);

y2=sin(pi/2*x2);
figure (1)
xlabel ('n')
subplot(4,1,1),stem (n, x1,
title ('x1[n]')
xlabel ('n')
subplot(4,1,2),stem (n, y1,
title ('y[n]')
xlabel ('n')
subplot(4,1,3),stem (n, x2,
title ('x2[n]')
xlabel ('n')
subplot(4,1,4),stem (n, y2,
title ('y[n]')

'filled')
'filled')
'filled')
'filled')

Kết quả :

10


11


Q: Is y2 equal to 2y1, what is your comment?
Trả lời : Giá trị biên độ của y2 thay đổi tăng 2 lần so với ban đầu

2. Causality
Exercise 2
The system y[n] = x[n] + x[n+1] is not causal. Use the input signal x[n] = U[n] toshow this,
as follows:
- Define the time (sample) interval to be between -6 and 9, and label it as n.
- Define the signal x[n]=U[n] as an array
with the values 0 for n<0 and 1 for n>=0
and label it as x.
- Define the signal x[n+1] =U[n+1] as an array of zeros for n<-1 and 1 for n>=-1
and label it as x_shift.
- Define the output signal y[n] as x[n]+x[n+1] .
- On the same window, plot the signals x[n], x[n+1] and y[n] using the commands
(subplot) and (stem).You should have a plot identical to the one shown in Figure 2.
Trả lời :
% Exercise 2
%Nguyen Van Vinh Hoa code
n = [-6:9];
x=zeros(1,length(n));
x_shift=zeros(1,length(n));
y=zeros(1,length(n));
for a=1:16
if n(a)<0
x(a)=0;
else
x(a)=1;
end
end
for b=1:15
if n(b)<-1
x_shift(b) =0;

else
x_shift(b) =1;
end
end
y=x+x_shift;
figure (2)
xlabel ('n')
subplot(3,1,1),stem (n, x, 'filled')
title ('x[n]')
xlabel ('n')
subplot(3,1,2),stem (n, x_shift, 'filled')
title ('x[n+1]')
12


xlabel ('n')
subplot(3,1,3),stem (n, y, 'filled')
title ('y[n]')

Kết quả :

13


Q: What is your comment about the system causality?
Trả lời : Tín hiê ̣u đầu ra sẽ phụ thuộc vào tín hiê ̣u đầu vào của hê ̣ thớ ng
3. Stability
Exercise 3
The system y[n]=log(x[n]) is not stable because the (log) function goes to minus
infinity at the 0 input. Write a MATLAB code to illustrate this. Proceed as follows:

- Define the domain vector as n ranging between -2 and 3.
- Define the input signal x as a vector of the values: 1, 2, 0, 3, 4 and 5.
- Declare the output vector as y= log(x). using the(log) function.
- Using stem and subplot commands, plot the input signal x[n] and the
corresponding output signal y[n]. The result should appear as shown in
Figure 3.
Trả lời :
%Nguyen Van Vinh Hoa code
%Exercise 3
n=[-2:3];
x=[1 2 0 3 4 5];
y=log(x);
figure(3)
xlabel ('n')
subplot(2,1,1),stem (n, x, 'filled')
title ('x[n]')
xlabel ('n')
subplot(2,1,2),stem (n, y, 'filled')
title ('y[n]')

Kết quả :

14


Q: Comment on your result. How does this result indicate that the system is
unstable?
Hê ̣ thố ng tăng dần từ -2 đến 3 nhưng tới điểm 0 thì tín hiê ̣u không tăng và tăng đều
từ 1


15


4. Invertible and Inverse
Systems
Exercise 4
The system y[n] = sin(2πx[n]) where x[n]=[0 1 2 3 4 0] is not invertible. Illustrate
this by showing that the system is not one-to-one. As follows:
- Define a vector of n values of 0,1,2,3,4 and 5 and label it as n.
- Define x[n] as a vector of the values 0,1,2,3,4 and 5.
- Define the output as y[n] = sin(2πx[n]).
- Plot x[n] and y[n] using the commands (stem) and (subplot). Your result shouldbe
as shown in Figure4.
Trả lời :
%Nguyen Van Vinh Hoa code
%Exercise 4
n=[0 1 2 3 4 5];
x=[0 1 2 3 4 0];
y=sin(2*pi*x);
figure(4)
xlabel ('n')
subplot(2,1,1),stem (n, x, 'filled')
title ('x[n]')
xlabel ('n')
subplot(2,1,2),stem (n, y, 'filled')
title ('y[n]')

Kết quả :

16



Q: Comment on the result justifying the claim that the system in not invertible
Hê ̣ thớ ng có thể đảo ngược và hê ̣ đảo ngược là hê ̣ mà từ tín hiê ̣u đầu ra ta có thể xác
định một cách chính xác tín hiệu đầu vào.

17


LAB 4 : THE CONVOLUTION SUM AND INTEGRAL
Exercise 1
Use MATLAB to evaluate the convolution of x[n] with itself, where

Procedure:
- Define the signal x as a vector of values [ 1 1 1 1 1 1], using the (ones)
command.
- Use the (conv) function to evaluate the convolution of x with itself, and name it
as y.
- Define the index vector n to range from 0 to 10.
- Using the function (stem), plot y versus n.
- Label the vertical and horizontal axes as (Amplitude) and (Time), respectively.
- Title the figure as (y[n]).
Trả lời:
%Nguyen Van Vinh Hoa code
%LAB4
%Exercise 1
x=ones(1,6);
y=conv(x,x);
n=[0:10];
figure(1)

stem(n, y, 'filled')
xlabel('Time')
ylabel('Amplitude')
title ('y[n]')

Q: Comment on the relationship between the length of y[n] and x[n]

18


Exercise 2
I.
Consider the discrete time signals:

 Define the signal x as a vector of values [0 1 2 3 4 5].
 Define the signal u as a vector of values [ 1 1 1 1 1 1], using the (ones)
command.
 Use the function (conv) function to evaluate the convolution of x with u, and
name it as
y.
 Define the index vector n to range from 0 to 10.
 Using the function (stem), plot y versus n.
 Label the vertical and horizontal axes as (Amplitude) and (Time), respectively.
 Title the figure as (y[n]).
Trả lời:
x= [0:5];
u=ones(1,6);
y=conv(x,u);
n=[0:10];
figure(1)

stem(n,y,'filled')
ylabel('bien do')
xlabel('thoi gian')
title('y[n]')

II. Repeat part I using u[n+5] instead of u[n].
Trả lời:
19


x=[0 1 2 3 4 5];
u=ones(1,6);
y=conv(x,u);
n=[-5:5];
figure(1)
stem(n,y,'filled')
xlabel('Thoi gian')
ylabel('bien do')
title('x[n]*u[n+5]')

Q: Comment on the relationship between y[n] in part I, and y[n] of part II.
Trả lời: Biên độ ở y[n] phần 1 bắt đầu ở khoảng thời gian là 0 kết thúc ở 10 và biên
độ tăng dần theo mố c thời gian 0 đến 6 và bắt đầu giảm dần.
Biên độ y[n] ở phần 2 bắt đầu ở khoảng thời gian -5 kết thúc ở 6 và biên độ tăng
dần theo mố c thời gian -5 đên 0 và bắt đầu giảm dần.
Exercise 3
In this part, continuous time convolution will be simulated in the discrete case.
Consider the
continuous time signals x(t) and h(t). Generate these functions using a time step of
0.1.


Procedure:
 Define the domain of x as a vector ranging from 1 to 5, with a time step of 0.1.
Name it
as tx.
 Define the domain of h as a vector ranging from 2 to 7, with a time step of 0.1.
Name it
20


as th.
 Define the signal x as a vector of ones over the index vector tx, using the
(ones),(length)
command,
 Define the signal h as a vector of ones of the index vector th, using the (ones)
),(length)
command
 Declare the total time length of the convolution to range from 3 to 12, with a 0.1
step.
Name it as ty.
 Use the function (conv) function to evaluate the convolution of x(t) with h(t),
and name it
as y. Hint: Don’t forget to multiply the conv. by Ts=0.1 (Ts step time)
 Using the function (stem), plot y versus ny.
 Label the vertical and horizontal axes as (Amplitude) and (Time), respectively.
 Title the figure as (y(t)).
Trả lời:
tx=1:0.1:5;
th=2:0.1:7;
x=ones(1, length(tx));

h=ones(1, length(th));
ty=3:0.1:12;
y=0.1*conv(x, h);
stem(ty,y,'filled');
ylabel('bien do')
xlabel('thoi gian')
title('y(t)');

Q: Comment on the relationship between the time length of y(t)and that of x(t) and
h(t)

21


LAB 5:DIFFERENTIAL EQUATIONS
1. LTI Systems Described by Differential Equations:
Exercise 1

Consider the causal LTI system described by the first order differential equation:
The latter equation can be rewritten as
Write a MATLAB code to simulate the step response of this system. This can be
done as
follows:
 Define the system coefficient vectors(a) and (b)
 Define the time vector t ranging from 0 to 10, with a 1 time increment.
 Define input as a row vector x of ones with the same length of t.
 Use the function (lsim) to evaluate the output y.
 Plot the output vector y versus time vector t with dashed lies (- -).
 Label the axes as the (output), (time), respectively.
 Title the figure as (Simulated Output).

To compare the simulated output to the actual one, plot the solution of the
differential equation
versus time as follows:
 Define the time vector t ranging from 0 to 10, with a 1 time increment.
 Plot the function
, versus time.
 Label the axes and title the figure as( Exact Output)
 Your answer should be as indicated in Fig1 .
Trả lời:
a = [1,1/2];
b = [1];
t = [0:1:10];
x=ones(1,length(t));
y=lsim(b,a,x,t);
plot(t,y,'--');
title('simulated output');

22


Exercise 2
Following a similar procedure to that of exercise 1, use (lsim) to compute the
response of the system:

To the input:
Your answer should be as indicated in Fig2.
b=1;
a=[1, 2];
t= 0:0.01:10;
x=t>=2;

y= lsim(b, a, x, t);
plot (t, y);
xlabel('time');
ylabel('output');
title('Response of the System');

23


Exercise 3
Plot the step and impulse responses of the system described by:

Proceed as follows:
 Define the system coefficient vectors(a) and (b)
 Define the time vector t ranging from 0 to 10, with a 0.1 time increment.
 Define input as a row vector x of ones with the same length of t.
 Use the function (step) to evaluate the step response of the system, and name it
as s.
 Use the function (impulse) to evaluate the step response of the system, and name
it as i.
 Use the command (subplot) to plot the step impulse response(s) on the top, and
impulse
response (i) in the bottom of the same graph window.
 Label the axes and title the figures.
 Your answer should be as indicated in Fig2.
Trả lời:
b = 1;
a = [1, 0.5];
t = 0:0.1:10;
ys = step(b,a,t);

yi = impulse(b,a,t);
subplot(2,1,1);
plot(t,ys);
xlabel('time');
ylabel('output');
title('Step Response');%bước đáp ứng
subplot(2,1,2);
plot(t,yi);
xlabel('time');
ylabel('output');
title('Impulse Response'); %đáp ứng xung

24


25


×