Professional Documents
Culture Documents
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
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]
Kết quả: