Documente Academic
Documente Profesional
Documente Cultură
LAB # 5:
“DSP USING SIMULINK”
Simulink:
Simulink software models, simulates, and analyzes dynamic systems. With Simulink,
we can easily build models from scratch, or modify existing models to meet our
needs.
Simulink Block:
TASK 1:
Sine Wave - Generate sine wave, Scope and Floating Scope - Display
using simulation time as time signals generated during
source simulation
Library Library
Sources Sinks
Description Description
COMMAND WINDOW:
>> f1=1000;
>> fsamp=10000;
>> Tsamp=1/fsamp;
MODEL WINDOW:
Sine Wave 1
Scope
SCOPE:
Conclusion:
The figure above shows a sine wave in time domain. The wave has changed
from its usual shape because of sampling time which is 1/10000 or 0.1 msec.
In the figure it can be seen that for every 0.1 ms the graph remain flat and
after 0.1 ms, it changes its level.
The model for part 1 can be used for this part also. The only difference is that
we have to change the Final time of the simulation according to the give time i.e.
5 periods. For 5 periods set the time to 5*T, where T is 1/1000 and hence final
time is 5/1000.
SCOPE:
>> stem(d(:,1),d(:,2))
2
Amplitude
-1
-2
-3
-4
-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time index -3
x 10
(b) Change the f1 to 21 kHz and investigate the output signal. Compare to
part (a) and comment.
-1
-2
-3
-4
-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-3
x 10
Result:
For f1 = 21 kHz. The Scope graph remains the same n “Amplitude vs. Time
index “graph is also same as was for 1 kHz f1. This shows that 1 kHz and 21
kHz signals are aliases of each other.
-1
-2
-3
-4
-5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-3
x 10
Result:
It can be seen that the figure in part (c) is anti-alias of part (a) because the
signals are opposite of each other. The sample at 5 in figure of part (c) is at 0
of figure of part (a) and vice versa.
(d) For the above cases, give the digital frequencies and indicate if they have
aliases in the range 0 ≤ f ≤ 5 kHz.
TASK 2:
(a) Using Simulink, assuming fsamp = 10 kHz, and a simulation time of 10msec, find
the step response.
2+z-1
1-1.7654 z -1+0.81 z -2
NOTE: The time is in seconds. Also I have set final time to 60 sec. because after 70 sec
there is no change in amplitude and it remains same.
70
60
50
amplitude
40
30
20
10
0
0 10 20 30 40 50 60
Time index n
(b) Determine the steady-state value, Go. Hence, plot the transient response,
ytran. (Hint : Use the model shown in Figure 2.)
The value of Go can be observed from the graph.
(c) If the input is a pulse equivalent to x(n) = u(n) - u(n - 25), find the pulse
duration in
msec, and hence determine the pulse response.
(Hint: Use the model shown in Figure 3).
2+z -1
Step 1+1.7654 z-1+0.81 z -2
Step 1
Command Window:
Time=b2(:,1);
Fsamp=10000;
n=Time*Fsamp;
step_resp=b2(:,2);
subplot(2,1,1);
stem(Time*1e4,step_resp);
grid on;
xlabel('Time in msec');
ylabel('Amplitude');
title('Step Response');
subplot(2,1,2);
stem(n,step_resp);
grid on;
xlabel('Time_index,n');
ylabel('Amplitude');
Scope:
PulseResponse
100
50
Amplitude
-50
0 0.5 1 1.5 2 2.5 3 3.5
Timein msec 5
x 10
PulseResponseVs TimeIndex n
100
50
Amplitude
-50
0 0.5 1 1.5 2 2.5 3 3.5
Timeindex,n 5
x 10