ECE-2026 Lab #3 Spring-2023 LAB COMPLETION REPORT Name: Ivan Mix, Carl Cort, Christian Choi, Adnan Porbanderwala Part 3.1 Chirp Aliasing (a) Chirp formula: cos(ψ(t)) = cos(2𝜋µ𝑡 2 + 2𝜋𝑓0 + 𝜑) = 𝒄𝐨𝐬(𝟐𝝅(𝟕𝟓𝟎𝒕𝟐 + 𝟔𝟐𝟓 + 𝒓𝒂𝒏𝒅𝒐𝒎) (b) LSECT = 128 samples and TSECT = 0.0512 sec (c) Guess why there are “ups and downs” in spectrogram (more about sampling and aliasing in Lab #4): The “ups and downs” are caused by aliasing. More specifically, the negative sloped parts are the folded sections (like the time segment between fs/2 and fs) while the positive sloped sections other than the first positive sloped part at the beginning of the graph are simple aliasing. Then it alternates back and forth between folding and simple aliasing. Code: %% 3.1 clc; clear; close all fSamp = 2500 %-Number of time samples per second dt = 1/fSamp; tStart = 0; tStop = 5; tt = tStart:dt:tStop; mu = (8125 - 625)/(tStop - tStart)*0.5 fzero = 625; phi = 2*pi*rand; %-- random phase Lsect = 128; Tsect = Lsect*dt % psi = 2*pi*mu*tt.*tt + 2*pi*fzero*tt + phi; %% <=================== FILL IN THE CODE HERE % cc = real( exp(j*psi) ); %soundsc( cc, fSamp ); %-- uncomment to hear the sound plotspec( cc+j*1e-12, fSamp, Lsect ), colorbar, grid on %-- with negative frequencies xlabel("sec") ylabel("Hz") % I messed around with it and if you sample at a higher frequency it sounds % and looks like a simple chirp signal instead of having aliasing issues Part 3.2 Spectrogram of periodic full-wave rectified sine wave using a long section duration. (b) TSECT = 1 sec and LSECT = 5000 samples (d) List frequencies of visible harmonics = I can see horizontal lines (frequencies) at +-0, +-2, +-4, +-6, +-8 (Hz)... there are probably very faint ones at +-10Hz, and so on (2kHz where k is an integer), I just can't see them because they are too faint or the Tsect is not long enough to have that resolution (e) Fundamental Frequency = they are at every 2n, therefore fundamental is 2Hz (f) |a1|= -0.2122 |a3|= -0.0182 and dB difference = abs(20*(log10(a3) - log10(a1))) = 20*(log10(a1/a3)) = 21.3389Db Code: %% 3.2 clc;clear;close all %% Fill in the values fs = 1000; Amp = 1; T = 1; %period tStop = 5; tt=0:(1/fs):tStop; xx=Amp*abs(sin(2*pi*tt/T)); Tsect = 5; Lsect = Tsect*fs figure plot(tt,xx); title('Full-wave Rectified Sine'); xlabel('t [sec]') figure plotspec( xx+j*1e-12, fs, Lsect ), colorbar, grid on %-- with negative frequencies ylabel("Hz") xlabel("sec") % *****Hint: Zoom in on the verticle axis to see the harmonics***** % Fundamental freq = ??? %% GUI fseriesdemo %<==Uncomment to use the GUI %I can see horizontal lines (frequencies) at 0, 2, 4, 6, 8 (Hz)... there is %probably a very faint one at 10 and so on, I just can't see it % a1= - 2/(3*pi) % a3= - 2/(35*pi) % (e) since there are lines every 2, gcd is 2, fundamental frequency = 2Hz % 1st mag = .212 3rd mag = 0.018 Part 3.3 Questions about decibels: (a) Explain 6 dB. A 6 decibel difference means the amplitude is twice as large, because if you look at something that is not in decibels and compute the difference, logarithm properties allow you to combine the difference into a single logarithm of the ratio of the two. If the first one is twice the other, this will be log10(2), which is about 0.3, and when you multiply by 20 (20log10(x) is its value in decibels) that will be 6Db. (b) dB difference between |a1|and |a3| = 21.3389Db (from 3.2f)… this is again because the decibel value of the first one minus the second one can be found by = 20log10(a1) – 20log10(a3) = 20(log10(a1) – log10(a3)) = 20log10(a1/a3)… and a1/a3 = 35/3 which gives 20log10(a1/a3) = 20 * 1.0669 = 21.3389Db Code: %% 3.3 clc;clear;close all a1 = - 2/(3*pi) a3 = - 2/(35*pi) dB_difference = abs(20* (log10(a3) - log10(a1)) ) Part 3.4 dB-Spectrogram of periodic full-wave rectified sine wave using a long-duration section. (a) List frequencies of harmonic lines = for part (a) there are lines every 2kHz where k is an integer and for part (b) there are lines every kHz where k is an integer. (b) Best value of TSECT = 4 seconds Zoomed in images of the decibel color-scaled plots of the two rectified sin waves spectrograms. The plot on the left is the fully rectified sin wave with one second period and on the one on the right is the one with a 2 second period. Below it are the plots not zoomed in as much. Code: %% 3.2 clc;clear;close all %% Part(a) fs = 1000; Fill in the values Amp = 1; T = 1; tStop = 5; tt=0:(1/fs):tStop; xx=Amp*abs(sin(2*pi*tt/T)); Tsect = 5; Lsect = Tsect*fs; DBrange = 10000; figure plotspecDB( xx+j*1e-12, fs, Lsect, DBrange), colorbar, grid on %-- with negative frequencies ylabel("Hz") xlabel("sec") %% Part(b) fs = 1000; Amp = 1; T = 2; tStop = 5; Fill in the values tt=0:(1/fs):tStop; xx2=Amp*abs(sin(2*pi*tt/T)); Tsect = 4; Lsect = Tsect*fs; DBrange = 10000; %decimal val of 80dB = 10^(80/20) figure plotspecDB( xx2 + j*1e-12, fs, Lsect, DBrange), colorbar, grid on %-- with negative frequencies ylabel("Hz") xlabel("sec") Part 3.5 Using the voice signal that you have recorded for Lab #1, make a linear and a dB spectrogram with a long section length, e.g., LSECT = 512. Since the vowel region of the recording is a signal that is quasi-periodic, the spectrograms should exhibit a harmonic line characteristic (parallel horizontal lines) during that time. Try different section lengths LSECT until the harmonic lines are easy to see in the spectrograms. Tried several LSECTs and found that 440 samples was the best LSECT for overall clarity. Using this LSECT, the spectrogram plots look like this (regular color scaling on the left and Db color scaling on the right: Based on the plots, within the vowel region (the set of roughly harmonic lines around 0.4secs) there are frequency lines at about ~130, 260, 400, 540 Hz. Based on this, it looks like the fundamental frequency is about 130Hz. Code: %% 3.5 clc; clear; close all [xx,fs] = audioread('ece2026lab1.wav'); Tsect = 0.055; Lsect = Tsect*fs DBrange = 80; % Linear spectrogram figure plotspec( xx, fs, Lsect), colorbar, grid on %-- with negative frequencies ylabel("Hz") xlabel("sec") % DB spectrogram figure plotspecDB( xx, fs, Lsect, 10^(DBrange/20)), colorbar, grid on %-- with negative frequencies ylabel("Hz") %Scale is still Hz but color grading is in decibells xlabel("sec")