Lab 1
Lab 1
Matlab Code:
close all, clear all, clc;
Fs = 5000, Ts = 1/Fs;
f = [500,2000,3000,4500] %initializing an array to observe output at different
frequencies
figure,
for i = 1:length(f) %initializing for loop for multiple CTCV plots
F = f(i);
t = [0:0.000005:0.2];
xt = sin(2*pi*F*t);
hold on
subplot(2,2,i);
plot(t,xt,'LineWidth',2)
xlabel('Time(sec)'), ylabel('Amp'), xlim([0 0.005]), grid on;
title('CTCV Sinusoid');
end
hold off
figure,
for i = 1:length(f) %initializng another for loop for DTDV plots
F = f(i);
nTs = [0:Ts:0.02]; %sampling of CTCV signal
n = [1:length(nTs-1)]; %array for DTDV
xn = sin(2*pi*F*nTs);
hold on
subplot (2,2,i);
stem (nTs, xn, 'LineWidth',2); %function for DT plot
title ('DTDV'), xlim([0 0.005]);
grid on, xlabel('Discrete time (samples/cycle)'), ylabel('Amp');
end
hold off
Similarities:
Plot 1 looks exactly similar to the plot 4 while plot 2 looks similar to the plot 3 in the discrete time.
Dissimilarities:
If we observe the plots in continuous time, Plot 1 and plot 4 are distinct while plot 2 and plot 3 are also
distinct which is contrary to what observed in discrete time.
Comments: It can be said that the frequencies of 3000Hz and 4500Hz are under-sampled since Fs =
5000Hz and does not match the Nyquist’s criteria i.e. Fs>=2F. Therefore, Plot 4 and plot 3 looks like an
aliased version of plot 1 and plot 2 respectively.
2. Generate a tone in MATLAB with varying frequency f = 1000,2000,3000,4000, 5000,
6000, 8000, 9000, 25000,-1000,-2000,-3000 Hz with Fs = 8000 samples/sec. Listen to
the tones, and observe at Sounds like what frequency? Also Specify whether Aliasing is
happening or not.
Matlab Code:
clear all, close all, clc;
F = -3000; %Differrent frequencies are placed here to observe different
sampled sounds
Fs = 8000, Ts = 1/Fs;
nTs = [0:Ts:1];
x = cos(2*pi*F*nTs);
sound(x);
Comments:
Unique sounds were observed at frequencies ranging from 1kHz - 4kHz. The negative
frequencies also produced the same sound as positive frequencies verifying the Nyquist’s
criteria of –Fs/2. 7kHz, 9kHz and 25kHz were an aliased version of 1kHz while 6kHz of 2kHz and
5kHz of 3kHz. 8kHz did not produce a sound at all because it is an alias of 0Hz which represents
a DC value.
3. Record a sentence in your voice.(you may use Simulink /audacity to record).Change Fs
=44100, 22050, 11025, 8192, 4096 , 2048 , 1024 and observe
a) Voice quality during playback [Excellent/Good/OK/Bad]
b) File size in kilobytes
c) Aliasing happening or not?
Using DSP system tool box in Simulink observing my voice at different sampling rates