how is the frequency vector and index vector derived?

3 views (last 30 days)
Hi All. I am trying to learn Fourier analysis and mathlab, I found the following piece of code on this forum but I can't seem to understand few lines in the code I was hoping you could help me understand.
first, how is the Fv Derived? can someone please help me understand what this piece code is doing
second, similary with index vector
and finally FTs_Plot ; why do we take the abs of FT(iv) dividing it with the maximum of itself?
i think I am able to understand what the rest of the code is doing except for those threee lines.
thanks in advance for your help.
D = load('time_domain.txt');
t = D(:,1);
s = D(:,2);
L = numel(t); % Vector Length
Ts = mean(diff(t)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTs = fft(s)/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
FTs_plot = abs(FTs(Iv))/max(abs(FTs(Iv))); % Normalised Fourier Transform
figure
plot(Fv, FTs_plot)
grid
xlim([0 0.5])
  2 Comments
KSSV
KSSV on 19 May 2020
You try simly plotting plot(FTs).
The above will give you two symmetric frequency plots. We need to pick only half of the plot. The steps you have mentioned are to pick the half of the plot. And divison is to normalize the frequency plot.
S Pro
S Pro on 22 May 2020
KSSV thanks for your response. Could you please break down and explain each line of code Fv, Iv and FTs_plot lines separerly please. I am confused specifically on those 3 lines.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!