MATLAB Answers

Spectrum Analysis Issues for FDR

2 views (last 30 days)
Mitch Lautigar
Mitch Lautigar on 7 Jul 2020
Hello Everyone,
In a nutshell, I'm having an issue with scaling/resolution when I try and take the FFT of a signal. I've attached the figures I see from my program in the fdr_issue.jpg attached.
On this file:
  • Figure Titled "Sin Wave": is the output from a simulation that I run. I know I can take the time difference between the peaks and invert them to obtain the frequency I'm looking for. In this case, 0.001 254 5 - 0.000 210 82 = 1 mSec roughly. This correlates to a frequency of 958.1481 Hz.
  • Figure Titled "Frequency Spectrum": is the output after taking the FFT of the above signal. Notice, the two different frequencies when I expect only 1 peak.
Below is matlab code that be copied by anyone trying to assist me. You will need to download the 'S_m2.mat' file from the link directly below.
Inputs for Matlab code below
fs = 5e9;
s_m2 = load('s_m2.mat');
n = 2^nextpow2(length(s_m2)); %Find next power of 2 up from length of S_m2
f = 0:fs/n:fs/2-fs/n; %Modulated frequency scale.
y = fft(s_m2,n); %FFT Transform, go to frequency domain
p2 = abs(y/length(s_m2)); %Put power spectrum on a resonable scale.
p1 = p2(1:n/2+1); %Look at left half of frequency spectrum.
p1(2:end-1) = 2*p1(2:end-1); %doubles values so frequency peaks are easy to see.
p1_test = p1 .* (1/max(p1) ); %Scale the power scale to have the highest peak be equal to 1 for visualization.
xlim([0 250e3])
xlabel('Frequency (Khz)')
title('Frequency Spectrum')
I'm assuming I need more resolution since the outputs I'm looking at are at a smaller frequency, but i'm at a loss of how to obtain it. If anyone can shed any guidance, it would be greatly appreciated. It can also be assumed that the S_m2.mat file numbers can be considered incredibly accurate (99% Confidence interval).


Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by