Spectrum Analysis Issues for FDR

4 views (last 30 days)
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.
https://drive.google.com/file/d/1Gs40la0q0lU7QDfMh0-xusgb-dAPOlka/view?usp=sharing
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.
figure
plot(f,p1_test(1:n/2))
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).

Accepted Answer

Mitch Lautigar
Mitch Lautigar on 28 Jan 2021
For those wondering, the solution was to scale down the numerical values (therefore decreasing memory requirements and allowing me to require higher resolution.)
What this looks like is instead of using:
f1 = 2e9;
f2 = 2.1e9;
fs = 5e9;
I use the following:
scaling = 1e6;
f1 = 2e9/scaling;
f2 = 2.1e9/scaling;
fs = 5e9/scaling;

More Answers (0)

Community Treasure Hunt

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

Start Hunting!