Fourier transform of text data

8 views (last 30 days)
Aike
Aike on 22 Aug 2011
Commented: Erd Akt on 3 May 2020
Hi everyone,
I have the Text data which part of my data is shown below:
-197 -196 -187 -172 -174
-173 -157 -135 -112 -106
-106 -98 -100 -106 -107
-119 -122 -100 -86 -109
-122 -95 -80 -84 -75
-37 -20 -29 -16 4
23 33 44 67 80
100 113 103 107 128
138 126 116 112 98
76 50 44
-1 -23 -48 -76 -102
-121 -142 -159 -188 -221
-245 -274 -284 -291 -309
-305 -296 -312 -331 -320
-313 -322 -311 -288 -262
-252 -251 -237 -230 -229
-220 -209 -189 -170 -169
-177 -189 -188 -188 -194
-196 -207 -209 -205 -205
-206 -205 -210 -211 -189
-174 -172 -161 -155 -162
-169
-189 -183 -165 -143 -129
-120 -108 -84 -59 -42
-26 -4 28 54 71
96 121 137 131 118
120 123 131 128 100
71 64 63 49 38
The sampling rate of data was 20Hz that started from 00:00:00UT to 23:59:59 UT. I don't know how to calculate Fourier Transform (FT) of the data using MATLAB. Moreover, I need to plot the power spectrum of the data on a graph. The x-axis should be frequency (Hz) and y-axis should be power spectrum. Could you help me calculate FT and plot a graph of power spectrum? Thank you very much.
Regards, Aike

Answers (3)

Fangjun Jiang
Fangjun Jiang on 22 Aug 2011
help fft

Honglei Chen
Honglei Chen on 22 Aug 2011
You need to first load data into MATLAB and then perform FFT. Assume that each column is a different data set, you can do something like
load data.mat
xfft = fft(x) % assume the data is in x
For the power spectrum, you can use spectrum object, e.g., to get the power spectrum for the first dataset,
h = spectrum.Periodogram
psd(h,x(:,1),'Fs',20)
HTH
  1 Comment
Erd Akt
Erd Akt on 3 May 2020
Hi Mr. Chen,
Your answer can help me for beginning. I'm new and I've project. My question;
  • I've 36 months sales data and I have to use fft and obtain Fourier complex numbers.
  • frequency, amplitude, A, B coefficient ets.
  • Then I obtain Fourier formula to forecats next 12 months.
How can I progress?

Sign in to comment.


Arturo Moncada-Torres
Arturo Moncada-Torres on 22 Aug 2011
I recommend you to check this wonderful tutorial by Quan Quach. Just remember the power spectrum is the square of the magnitude component of the signal.

Tags

Community Treasure Hunt

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

Start Hunting!