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

  • MATLAB
  • Thread starter RAYINDASKY
  • Start date
  • Tags
    Fft Matlab
In summary, the conversation discusses the process of converting data from an excel file to the frequency domain. It includes a code for analyzing frequency components and plotting them, but the results obtained may not be accurate due to confusion with Fourier transforms and histograms. The solution is to use Matlab's hist command to correctly determine the number of occurrences for each value in the data.
  • #1
RAYINDASKY
2
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
  • #2
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)
 

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

What is the purpose of using the FFT function in Matlab?

The FFT function in Matlab stands for "Fast Fourier Transform" and it is used to analyze and extract the frequency components of a signal or data set. It is a tool commonly used in signal processing, image processing, and other scientific and engineering applications.

How do I use the FFT function in Matlab?

To use the FFT function in Matlab, you first need to have a data set or signal that you want to analyze. Then, you can simply type "fft(data)" in the command window, where "data" is the name of your data set or signal. This will return a complex array containing the frequency components of your data.

What is the difference between the FFT and the DFT?

The FFT (Fast Fourier Transform) is a more efficient algorithm for calculating the DFT (Discrete Fourier Transform). The DFT is a mathematical operation that converts a discrete signal from its original domain (often time or space) to a representation in the frequency domain. The FFT makes use of symmetries in the DFT calculation to reduce the number of operations required, making it much faster for large data sets.

How can I visualize the results of the FFT in Matlab?

Matlab has built-in functions for visualizing the results of the FFT, such as "plot(abs(fft(data)))" to plot the magnitude spectrum and "plot(angle(fft(data)))" to plot the phase spectrum. You can also use the "fftshift" function to rearrange the output of the FFT to have the zero frequency component in the center of the spectrum.

What are some common applications of the FFT in Matlab?

The FFT function in Matlab has a wide range of applications, such as analyzing sound and music signals, filtering out noise from images, detecting patterns in time series data, and solving differential equations. It is also commonly used in fields such as physics, engineering, and finance for data analysis and processing.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
764
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
Replies
5
Views
383
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
16
Views
13K
Back
Top