How do I get a table of data from an FFT analysis

2 visualizzazioni (ultimi 30 giorni)
Hi, I have been doing FFT analysis and happily plotting results in graphical form. Now I would like to see a table / list of the data that is being plotted. I know this should be simple, but being a relatively new user I don't know how this is done. Any help is appreciated.

Risposte (2)

Star Strider
Star Strider il 30 Nov 2016
What function are you using? The fft (link) function itself is straightforward to use.
For example, if you’re using freqz or freqs, you can get the complex frequency response and frequency vector by using the function with two outputs. See the documentation for details.
  2 Commenti
Star Strider
Star Strider il 1 Dic 2016
Max Higginbotham’s ‘Answer’ moved here (formatting added):
Hi,
Thanks for the answer, but I think I am looking for something simpler.
What I am doing is looking at a dataset with 16384 sample points. My script goes like this (it is abridged version)
% DP = imported variable data from excel file - 16384 data points
Ts=0.000122; % set time step in seconds
Fs=1/Ts; % set sampling frequency
N=16384; % set number of samples
bin_vals=[0 : N-1]; % set up for frequency scale
frequency=bin_vals*Fs/N; % set frequency scale variable
% This is my FFT bit
FFT_DP=abs(fft(DP));
FFT_DP_Mag=FFT_DP./N;
%Then I plot a graph using
plot (frequency,FFT_DP_Mag);
This is giving me a plot of frequency versus my variable. All I now want to get is a tabulation of this graphical plot. I know this should be simple.
Thanks for any help you can give.
Star Strider
Star Strider il 1 Dic 2016
My pleasure.
I would use the code between the first (top) two plot figures in the link I provided in my original Answer to code your fft. Rmemeber, you can only plot it up to the Nyquist frequency, so defining the frequency vector is important.
To print out your data, use fprintf or sprintf (they both use the same arguments, see the documentation on both for details). This will present your data with the frequency in the first column and the amplitude in the second column:
FFT_Freq_Mag = sprintf('%.4f\t%.4f\n', [frequency(:) FFT_DP_Mag(:)]') % Note: Transpose(') Of Matrix Of Column Vectors
This creates column vectors from your data for printing purposes (they are otherwise unchanged in your workspace), concatenates them in a (Nx2) matrix, transposes the matrix to present them in a way acceptable to the print function, and produces the output in the ‘FFT_Freq_Mag’ character array.

Accedi per commentare.


Max Higginbotham
Max Higginbotham il 1 Dic 2016
Hi, Thanks for the answer, but I think I am looking for something simpler. What I am doing is looking at a dataset with 16384 sample points. My script goes like this (it is abridged version)
% DP = imported variable data from excel file - 16384 data points Ts=0.000122; % set time step in seconds Fs=1/Ts; % set sampling frequency N=16384; % set number of samples bin_vals=[0 : N-1]; % set up for frequency scale frequency=bin_vals*Fs/N; % set frequency scale variable
% This is my FFT bit FFT_DP=abs(fft(DP)); FFT_DP_Mag=FFT_DP./N;
%Then I plot a graph using plot (frequency,FFT_DP_Mag);
This is giving me a plot of frequency versus my variable. All I now want to get is a tabulation of this graphical plot. I know this should be simple. Thanks for any help you can give.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by