Fast Fourier Transform from data in file
Show older comments
Hello everyone,
I am getting vector length error in a matlab code. The problem is that I don't know how to construct vectors properly.
The file contains single column of electric field time domain data. Number of rows are 19838, which means the time of recording is sampled at these points. Total time is around 33 picoseconds.
Now I want to convert this time domain data to frequency domain data in range 0.001 to 6 GHz. How should I sample my frequency?
My code:-
load Ez_time.txt
file = Ez_time;
aa = fft(file);
%File contains 19838 rows each correspoing to
% one time step. Total time is around 33 picoseconds.
T =length(file);
Fs = 1/T;
%For taking fft in a frequency range 0.001 to 6 GHz
freq = 0.001 : 1./T : 6;
plot(freq,abs(aa));
Alternatively, I also tried below written code, but this isn't giving me the right spectrum.
load Ez_time.txt
file = Ez_time;
aa = fft(file);
freq = linspace(0,6,19838);
plot(freq,abs(aa))
Accepted Answer
More Answers (1)
miki90
on 14 Dec 2017
0 votes
Hello. I didn't want to start the different topic for the same problem, so I will be thankful if anyone can help me. I have the data in the file, gained from the acquisition in LabVIEW. There is a matrix of voltages in the file, with frequency sampling of 1kHz, and the number of samples - 10000. I need to find the frequency range in which the signal belongs to, using these data. I tried to follow the example found on the Mathworks site, but I get only the straight horizontal line with the one peak at about 2.5, which is the magnitude. Can anyone help me with this task? Thanks in advance.
Categories
Find more on Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!