Converting Data to Frequency Domain using MATLAB's Fast Fourier Transform (FFT)

  • Context: MATLAB 
  • Thread starter Thread starter RAYINDASKY
  • Start date Start date
  • Tags Tags
    Fft Matlab
Click For Summary
SUMMARY

The discussion focuses on converting time-domain data to the frequency domain using MATLAB's Fast Fourier Transform (FFT). The original code provided by the user incorrectly interprets the results, mistaking frequency analysis for histogram counting. The correct approach involves using MATLAB's hist function to accurately represent the frequency of data occurrences. The user is advised to replace their FFT implementation with histogram analysis for the intended results.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of Fast Fourier Transform (FFT)
  • Knowledge of data visualization techniques in MATLAB
  • Basic concepts of histograms and frequency analysis
NEXT STEPS
  • Learn how to implement MATLAB's hist function for frequency analysis
  • Explore the differences between FFT and histogram representations of data
  • Study MATLAB's data visualization tools for effective plotting
  • Investigate advanced FFT techniques for signal processing in MATLAB
USEFUL FOR

Data analysts, signal processing engineers, and MATLAB users looking to accurately convert and visualize data in the frequency domain.

RAYINDASKY
Messages
2
Reaction score
0
I have data in excel file and want to convert that to frequency domain. I wrote the following code but its giving me the wrong results.

If my data is 2,2,2,5,5,6
Shouldn't

Amplitude =2 and frequency =3
Amplitude =5 and frequency =2
Amplitude =6 and frequency =1




%Read in the data
data = xlsread('time.xls');

%Analyze the frequency components.
y=2*abs(fft(data))/length(data);
%Plot frequency versus frequency componant magnitude, circle f_max
figure
plot(x,y)
xlabel('Frequency (Hz)')
ylabel('Amplitude ')
title('Frequency Domain ')
 
Physics news on Phys.org
You are confusing Fourier transforms with histograms. You are asking for the number of occurrences in your data of each value, which has absolutely nothing to do with FFT's. Instead use Matlab's hist command:

data = [2,2,2,5,5,6];
N = length(data);
y = hist(data,N)
bar(1:N,y)
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
8K