MATLAB Answers

Extraction of FFT from each segment for computation

1 view (last 30 days)
Chloe Sim
Chloe Sim on 16 Feb 2020
Commented: Star Strider on 18 Feb 2020
Hello! I have a code doing splitting of data size of 51200 into segments of 512 and did a FFT on each segment.
How do I extract the FFT from each of the 512 segment ?

  1 Comment

Sindar on 16 Feb 2020
Your question is unclear. What's already working and what do you need?

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 16 Feb 2020
If this relates to your earlier Question, the fft results are in each column of the ’P1’ matrix.
Y = fft(X-mean(X)); % FFT
f = Fs*(0:(L/2))/L;
P2 = abs(Y/L);
P1 = P2(1:numel(f),:); % Note: Added Column Dimension (I Did Not Catch That Omission Earlier)
so the first fft would be:
FT_1 = P1(:,1);
and so for the rest.


Show 1 older comment
Star Strider
Star Strider on 18 Feb 2020
My pleasure!
See if this answers your question:
P1 = rand(1,25601); % Create ‘P1’
L = 512;
X = buffer(P1, L);
Y = fft(X-mean(X))/L;
f = Fs*(0:fix((L/2)))/L;
P2 = abs(Y/L);
plot(f, P2(1:numel(f),1))
title('P2(:,1) = First Column')
xlim([0 max(f)])
plot(f, P2(1:numel(f),20))
title('P2(:,20) = 20^{th} Column')
xlim([0 max(f)])
Here, ‘P2’ has 512 rows and 51 colimns. Each column is a separate fft.
This also demonstrates how to address them and how to plot them.
Chloe Sim
Chloe Sim on 18 Feb 2020
Hello! Thank you for the fast response!
Is the code above showing each FFT of each segment? :)
Star Strider
Star Strider on 18 Feb 2020
It is showing the fft for the segments (columns) you choose. In that example, I plotted columns 1 and 20.
To show all of them in the same axes at the same time:
plot(f, P2(1:numel(f),:)
Experiment to get different results.

Sign in to comment.

Sign in to answer this question.