Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine...
Transcript of Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine...
![Page 1: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/1.jpg)
Sine Wave in Matlab
t = [ 0 : 1 : 40 ]; % Time Samplesf = 500; % Input Signal Frequencyfs = 8000; % Sampling Frequencyx = sin(2*pi*f/fs*t); % Generate Sine Wave figure(1);stem(t,x,'r'); % View the samplesfigure(2);stem(t*1/fs*1000,x,'r'); % View the sampleshold on;plot(t*1/fs*1000,x); % Plot Sine Wave
![Page 2: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/2.jpg)
Fourier Transform
% FFT LengthfftLength = 1024; % Signal LengthsigLength = length(x); % Rectangular Windowwin = rectwin(sigLength)'; % Find the DFTy = fft(x.*win,fftLength); % Figure LengthfigLength = fftLength/2 + 1; % Plot the Magnitude Response in Linear Scaleplot([1:figLength]*fs/(2*figLength),abs(y(1:figLength)));
% Plot the Magnitude Response in Log Scaleplot([1:figLength]*fs/(2*figLength),20*log10(abs(y(1:figLength))));
![Page 3: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/3.jpg)
Different Types of Windows
Length = 200;% Rectangular Window win = rectwin(Length); wRect = [zeros(200,1); win;zeros(200,1)];
![Page 4: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/4.jpg)
Different Types of Windows
Length = 200;% Hamming Window win = hamming(Length); wRect = [zeros(200,1); win;zeros(200,1)];
![Page 5: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/5.jpg)
Windowing Effects – Rectangular Window
![Page 6: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/6.jpg)
Windowing Effects – Hamming Window
![Page 7: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/7.jpg)
Frequency Resolution
Rectangular Window
Hamming Window
![Page 8: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/8.jpg)
Short Term Fourier Transform
Two sinusoids at 500 Hz and 750 Hz. One present from 0 – 125 ms and the second one from 125250 ms.
![Page 9: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/9.jpg)
Short Term Fourier Transform
Full signal Fourier Transform does not give time information.
![Page 10: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/10.jpg)
Short Term Fourier Transform
Narrow Band Spectrogram STFT with long analysis windows
![Page 11: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/11.jpg)
Short Term Fourier Transform
Wide Band Spectrogram STFT with short analysis windows
![Page 12: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/12.jpg)
Speech Signals
Male Speech – phoneme /a/
![Page 13: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/13.jpg)
Speech Signals
Male Speech – phoneme /a/
![Page 14: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/14.jpg)
Speech Signals
Female Speech – phoneme /a/
![Page 15: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/15.jpg)
Speech Signals
Female Speech – phoneme /a/
![Page 16: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/16.jpg)
Speech Signals
Child Speech – phoneme /a/
![Page 17: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/17.jpg)
Speech Signals
Child Speech – phoneme /a/
![Page 18: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/18.jpg)
Speech Signals
Male Speech – word beat
![Page 19: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/19.jpg)
Speech Signals
Male Speech – word beat
![Page 20: Sine Wave in Matlab - Johns Hopkins Universityclsp.jhu.edu/~sriram/lectures/matlab2.pdf · Sine Wave in Matlab t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency](https://reader031.fdocuments.net/reader031/viewer/2022021901/5b8a4a0a7f8b9a78618dbce9/html5/thumbnails/20.jpg)
Speech Signals
Male Speech – word beat