User Tools

Site Tools


analysis:course-w16:week5

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
analysis:course-w16:week5 [2016/01/21 15:32]
mvdm
analysis:course-w16:week5 [2018/07/07 10:19] (current)
Line 12: Line 12:
 Resources: Resources:
  
-  * (bakcground) {{:​analysis:​course:​weeks_ch4_sinusoids.pdf|Chapter 4}} from Weeks, "​Digital Signal Processing Using MATLAB & Wavelets"​+  * (background) {{:​analysis:​course:​weeks_ch4_sinusoids.pdf|Chapter 4}} from Weeks, "​Digital Signal Processing Using MATLAB & Wavelets"​
   * (background) {{:​analysis:​course:​weeks_ch6_fourierintro.pdf|Chapter 6}} from Weeks, "​Digital Signal Processing Using MATLAB & Wavelets"​   * (background) {{:​analysis:​course:​weeks_ch6_fourierintro.pdf|Chapter 6}} from Weeks, "​Digital Signal Processing Using MATLAB & Wavelets"​
   * (optional) [[http://​www.mathworks.com/​help/​signal/​ug/​spectral-analysis.html|MATLAB'​s guide to spectral analysis]]   * (optional) [[http://​www.mathworks.com/​help/​signal/​ug/​spectral-analysis.html|MATLAB'​s guide to spectral analysis]]
Line 24: Line 24:
 To study oscillations we require //​periodic//​ functions of time, such as ''​sin(t)'',​ which repeat its values in regular intervals. To study oscillations we require //​periodic//​ functions of time, such as ''​sin(t)'',​ which repeat its values in regular intervals.
  
-Recall that to plot this sort of function in matlab, we first define the time axis (commonly a variable with the name ''​tvec''​),​ pass this to the function we wish to plot as an argument, and plot the result:+Recall that to plot this sort of function in MATLAB, we first define the time axis (commonly a variable with the name ''​tvec''​),​ pass this to the function we wish to plot as an argument, and plot the result:
  
 <code matlab> <code matlab>
Line 33: Line 33:
  
 f = 2; % frequency of sine to plot f = 2; % frequency of sine to plot
-y = sin(2*pi*f*tvec);​ % note sin() expects arguments in radians, not degrees (see sind())+y = sin(2*pi*f*tvec);​ % note sin() expects arguments in radians, not degrees (see also ''​sind()''​)
  
 stem(tvec,​y);​ stem(tvec,​y);​
Line 300: Line 300:
 Computing a FFT over a window of finite size is as if we are taking a finite-size window (for instance ''​ w(n) = 1 if 0 <= n <= N; 0 otherwise'';​ note that this defines a //​rectangular//​ window) and multiplying this with a hypothetical infinite signal. ​ Computing a FFT over a window of finite size is as if we are taking a finite-size window (for instance ''​ w(n) = 1 if 0 <= n <= N; 0 otherwise'';​ note that this defines a //​rectangular//​ window) and multiplying this with a hypothetical infinite signal. ​
  
-It turns out that the spectrum of the windowed signal equals the //​convolution//​ of the signal'​s spectrum and the window'​s spectrum; this occurs because of the [[http://​en.wikipedia.org/​wiki/​Convolution_theorem|convolution theorem]] that states that multiplication in the time domain equals convolution in the frequency domain.+It turns out that the spectrum of the windowed signal equals the //​convolution//​ of the signal'​s spectrum and the window'​s spectrum; this occurs because of the [[http://​en.wikipedia.org/​wiki/​Convolution_theorem|convolution theorem]] that states that multiplication in the time domain equals convolution in the frequency domain. ​(If the idea of convolution is new to you, you can think of it as a kind of "​blurring":​ for instance, convolving a signal with a 5-point rectangular pulse is equivalent to taking the running average with a 5-point moving window. For a graphical exploration of this idea, see [[http://​pages.jh.edu/​~signals/​convolve/​ | this website]] or look at the MATLAB doc for the ''​conv()''​ function.) ​
  
 Thus, it becomes important to understand the spectral properties of the windows used for Fourier analysis. Let's plot a few: Thus, it becomes important to understand the spectral properties of the windows used for Fourier analysis. Let's plot a few:
Line 478: Line 478:
 <code matlab> <code matlab>
 % check if sampling is ok % check if sampling is ok
-plot(diff(csc_preR)); % only minimal differences +plot(diff(csc_pre.tvec)); % only minimal differences 
-Fs = 1./​mean(diff(csc_preR));+Fs = 1./​mean(diff(csc_pre.tvec));
 </​code>​ </​code>​
  
Line 494: Line 494:
  
 (Note that the above is a quick hack of something that should really be implemented in a nice function, because the above commands really correspond to one conceptual operation of decimation, presenting an opportunity for making the code more readable and maintainable. But I haven'​t gotten around to that yet.) (Note that the above is a quick hack of something that should really be implemented in a nice function, because the above commands really correspond to one conceptual operation of decimation, presenting an opportunity for making the code more readable and maintainable. But I haven'​t gotten around to that yet.)
 +
 +☛ Now that you have decimated the data, also update your sampling frequency ''​Fs''​.
  
 Now we can compute the spectrum: Now we can compute the spectrum:
Line 508: Line 510:
 {{ :​analysis:​course:​week4_fig7.png?​600 |}} {{ :​analysis:​course:​week4_fig7.png?​600 |}}
  
-Note that we are plotting not the raw power spectrum but rather the ''​10*log10()''​ of it; this is conventional so that the resulting units are in decibels ​(dB), the unit of signal power also applied to sound waves. ​+Note that we are plotting not the raw power spectrum but rather the ''​10*log10()''​ of it; this is a convention similar to that of the definition of the decibel ​(dB), the unit of signal power also applied to sound waves. The values on your vertical axis may look different, depending on what version of ''​LoadCSC()''​ was used.
  
 Regardless, it doesn'​t look very good! The estimates look very noisy, a characteristic of the periodogram method. Regardless, it doesn'​t look very good! The estimates look very noisy, a characteristic of the periodogram method.
analysis/course-w16/week5.1453408334.txt.gz · Last modified: 2018/07/07 10:19 (external edit)