How to plot Fourier transform of the signal from a text file (*.txt) ?

13 views (last 30 days)
Hello all, I want to plot the fourier transform of the signal data content from my Text file. I want to see how the frequency content look like. Can someone help me for this problem ? Thank you very much.
Sampling rate: 30 second ( after 30 second, the system will update the new data samples)
I attached the DATA.txt file and here is the content:
4/14/2021 3:46:24 PM 64131.513381 5823.895335 7017.153421 6695.069373 7413.178682 6956.152618 5334.056631 6891.041994
4/14/2021 3:46:54 PM 15529.222786 13262.592256 15858.717263 14706.268907 15880.517662 14049.395919 10740.444064 13349.786401
4/14/2021 3:47:24 PM 9038.478136 8078.046143 8044.146001 8139.73422 8534.342051 8134.812117 7425.203919 7708.273828
4/14/2021 3:47:55 PM 54023.002964 5627.088249 4928.067327 5023.099482 5247.063935 5547.463894 5676.805973 5406.416953
4/14/2021 3:48:25 PM 3981.173038 4461.616278 3718.629479 3848.016262 3935.739398 4449.620843 4675.038159 4347.358983
4/14/2021 3:48:55 PM 222.834491 258.781016 241.129270 247.694552 234.340470 253.140926 241.834396 244.542956
4/14/2021 3:49:25 PM 262.118876 274.784863 249.400735 248.014927 257.641077 275.291502 259.727240 273.302197
4/14/2021 3:49:55 PM 262.692571 275.559723 248.383456 247.783959 257.559121 276.73419 260.770321 274.509192
4/14/2021 3:50:25 PM 232.912600 239.737332 224.359334 225.216150 237.390399 237.007778 230.602920 240.758061
4/14/2021 3:50:55 PM 106.386840 143.93250 128.857791 131.532550 123.547695 183.440745 119.321048 113.576651
4/14/2021 3:51:25 PM 233.294747 337.659466 257.007778 255.376101 552.373423 279.303465 268.600881 241.263624
  3 Comments
Dung Tran
Dung Tran on 11 May 2021
Yes, there is 8 different chanels, so we have 8 different signal, one per column.
About the sampling rate, we have 8 samples of signal in 1 row, each sample will be update in every 30 second.
so basicly the sampling rate ( samples per second) will be 8 / 30 = 0.26 Hz.
Walter Roberson
Walter Roberson on 11 May 2021
If the different columns correspond to different channels, then each signal updates every 30 seconds, so the frequency of each signal would be 1/30 Hz.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 11 May 2021
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/614995/DATA.txt';
data = readtable(filename, 'readvariablename', false);
x = data{:,2:end};
f = fft(x - mean(x,1));
h = plot(abs(x));
size(h)
ans = 1×2
8 1
set(h, {'Marker'}, {'+', 'o', '*', '.', 'x', 'v', '^', '<'}.')
legend show

Tags

Community Treasure Hunt

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

Start Hunting!