You are on page 1of 12

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

LAB 5: DIFFERENTIAL EQUATIONS


Exercise 1:
Consider the causal LTI system described by the first order differential equation:
ⅆy ( t ) 1
= y ( t ) + x (t)The latter equation can be rewritten as
ⅆt 2
ⅆy ( t ) 1
= y ( t ) + x (t)Write a MATLAB code to simulate the step response of this system.
ⅆt 2
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 (Isim) 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 y=2(1-e -t/2 ), versus time.
• Label the axes and title the figure as(Exact Output)
• Your answer should be as indicated in Fig1 .

Code:
a=[1 0.5];
b=1;
t=0:1:10;
x=ones(1,length(t));
y=lsim(b,a,x,t);
plot(t,y,'--');
xlabel('time');
ylabel('output');
title('Simulated output');

Kết quả:
Code:
t=0:10;
y=2*(1-exp(-t/2));
plot(t,y,'--');
xlabel('time');
ylabel('output');
title('Exact Output');

Kết quả:
Exercise 2:
Following a similar procedure to that of exercise 1, use (Isim) to compute the response
of the system:
ⅆy ( t )
=2 y ( t )+ x(t)To the input:
ⅆt
x(t) = u(t − 2)
Your answer should be as indicated in Fig2.

Code:
a=[1 2];
b=1;
t=0:10;
x=min(1,max(0,t-1));
y=lsim(b,a,x,t);
plot(t,y);
xlabel('time');
ylabel('output');
title('Simulated output');

Kết quả:

Exercise 3:
Plot the step and impulse responses of the system described by:
ⅆy ( t ) −1
= y ( t ) + x (t) Proceed as follows:
ⅆt 2

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

Code:
a=[1 0.5];
b=1;
t=0:0.1:10;
x=ones(1,length(t));
s=step(b,a,t);
i=impulse(b,a,t);
subplot(2,1,1), plot(t,s);
xlabel('time');
ylabel('s');
title('s[t]');
subplot(2,1,2), plot(t,i);
xlabel('time');
ylabel('i');
title('i[t]');

Kết quả:
LAB 6: FOURIER SERIES AND FOURIER TRANSFORM REPRESENTATION
Exercise 1:
Consider using MATLAB to solve Problem 3.3(a) in (Simon Haykin 2nd Edition) book.
For the DTFS coefficient, the signal:
x [ n ] =1+sin ( nπ12 + 38π )This signal has period N=24.
Procedure:
• Define the signal period N.
• Define the index vector n to range from 0 to 23.
• Define the signal x as a vector of ones using the (ones) command plus sin valus. Also
plot the signal in figure 1 using stem.
•Use the function (fff) function to evaluate the DTFS coefficients. and store it in X.
• Plot the real and imaginary parts of fourier series coefficient x using subplot and stem
on figure 2.
• Plot the absolute value and angles of fourier series coefficient x using subplot and
stem on figure 3.
• Use the function (ifft) function to reconstruct the orginal time domain signal x and
store it in x_recon. Plot it on figure 4 as real and imaginary part using subplot.
Q: Comment on the relationship between figures of x[n] and x_recon?

Code:
N = 24;
n = 0:23;
x1 = 1 + sin(n*pi/12 + 3*pi/8)

figure(1)
stem(n,x1,'filled')
title('figure 1')

X = (1/N)*fft(x1);
X1 = real(X);
X2 = imag(X);

figure(2)
subplot(2,1,1), stem(n,X1,'filled')
subplot(2,1,2), stem(n,X2,'filled')
title('figure 2')

X3 = abs(X);
X4 = angle(X);
figure(3)
subplot(2,1,1), stem(n,X3,'filled')
subplot(2,1,2), stem(n,X4,'filled')
title('figure 3')
x_recon = N*ifft(X);
X5 = real(x_recon);
X6 = imag(x_recon);
figure(4)
subplot(2,1,1), stem(n,X5,'filled')
subplot(2,1,2), stem(n,X6,'filled')
title('figure 4')

Kết quả:
Exercise 2:
Consider the following difference equation:
y[n] 0.75y[n 1] + 0.6y[n − 2] = 2x[n] − x[n −2]

1) Evaluate the Frequency Response at 4 evenly spaced between 0 and π ?


Procedure:
•Define a and b to describe the previous causal LTI system as a vectors.
•Use freq with the coefficients a and b define H1 to be the value of the frequency
response at 4 evenly spaced frequencies between 0 and л and omegal to be those
frequencies.
2) Evaluate the Frequency Response at 4 evenly spaced between 0 and 2 π ?
Code:
a=[1 -0.75 0.6];
b=[2 -1];
N=4;
k=0:3;
H1=freqz(b,a,N)
w1=(pi/N)*k
H2=freqz(b,a,N,'whole')
w2=(2*pi/N)*k

Kết quả:

You might also like