Estimate SNR of Signal
Estimate the signal-to-noise ratio of a measured sine wave by comparing the power in the fundamental bin against the power in everything else.
Constraints
- Function: snr_db = estimate_snr(x, fs).
- Apply a window before the FFT to limit spectral leakage.
- Exclude the DC bin and the fundamental's immediate neighbours from the noise.
- Return the result in decibels.
- A constant signal must return -Inf or an error, not a NaN.
- Fewer than 8 samples must error.
1function snr_db = estimate_snr(x, fs)2% TODO3end