MEGR 3171  |  UNC Charlotte Mechatronics 2
Dr. Roger Tipton
Mechanical Engineering & Engineering Science
Back to Course Hub
Week 6 — Module 1: Precision Measurement & Signal Science

Frequency Domain Analysis & Curve Fitting

Decomposing signals into their frequency components using the FFT and extracting quantitative models from data using least-squares regression.

Learning Objectives

1. Fourier Series and the DFT

Any periodic signal can be expressed as a sum of sinusoids at the fundamental frequency and its harmonics. The Fourier series provides the theoretical foundation; the Discrete Fourier Transform (DFT) extends this to sampled, finite-length signals.

Key FFT Parameters
Frequency resolution: Δf = f_s / N (Hz per bin) where N = number of samples, f_s = sampling rate Record length: T = N / f_s (seconds) Useful frequency range: 0 to f_s/2 (Nyquist limit) Amplitude scaling: divide magnitude by N/2 for single-sided spectrum

The Fast Fourier Transform (FFT, Cooley-Tukey algorithm) computes the DFT in O(N log N) operations instead of O(N²), making it practical for real-time use. FFT works most efficiently when N is a power of 2.

2. Spectral Leakage and Windowing

The DFT assumes the signal is periodic within the record. If the signal does not complete an exact integer number of cycles, the abrupt truncation at the record boundaries introduces artificial frequency components called spectral leakage. A windowing function tapers the signal to zero at the record edges, reducing leakage at the cost of slightly reduced frequency resolution.

Rectangular Window

No tapering. Best frequency resolution but worst leakage. Acceptable only when signal frequency aligns exactly with an FFT bin.

Hanning Window

Good leakage reduction, moderate resolution reduction. Most common choice for general-purpose spectral analysis of continuous signals.

Hamming Window

Similar to Hanning but with slightly different coefficients. Better for some transient signals. Widely used in audio and vibration analysis.

Flat-Top Window

Best amplitude accuracy. Used when precise amplitude measurement is critical (calibration). Poor frequency resolution.

3. Linear Curve Fitting (Least Squares)

Given data pairs (xi, yi), find the best-fit line y = a0 + a1x that minimizes the sum of squared residuals.

Linear Regression Formulas
a_1 = [N∑(x_i y_i) - ∑x_i ∑y_i] / [N∑(x_i²) - (∑x_i)²] a_0 = (1/N)(∑y_i - a_1 ∑x_i) R² = 1 - SS_res / SS_tot SS_res = ∑(y_i - ŷ_i)² SS_tot = ∑(y_i - ȳ)² RMSE = √(SS_res / (N-2))

R² = 1.0 means perfect fit. R² = 0.99 means 99% of variance in y is explained by the model. For sensor calibration curves, R² > 0.9999 is typically expected.

Practice Problems

Problem 1 — Frequency Resolution An FFT is computed from 1024 samples collected at 8192 Hz. What is the frequency resolution? What is the highest frequency representable?

Δf = f_s / N = 8192 / 1024 = 8 Hz per bin

f_max = f_s / 2 = 8192 / 2 = 4096 Hz (Nyquist)

Frequency resolution = 8 Hz; Maximum frequency = 4096 Hz
Problem 2 — Spectral Leakage A 75 Hz sine wave is sampled at 1000 Hz for 0.1 seconds (100 samples). Will spectral leakage occur? Explain.

Frequency resolution = 1000/100 = 10 Hz. The FFT bins are at 0, 10, 20, ..., 70, 80, ... Hz. The 75 Hz signal falls exactly between the 70 Hz and 80 Hz bins. Since no bin aligns with 75 Hz, the record does not contain an integer number of cycles (75 Hz × 0.1 s = 7.5 cycles). Yes, significant leakage will occur. Apply a Hanning window to reduce it.

Yes, leakage will occur. 75 Hz falls between bins. Apply Hanning window.