caculate frequency from signal data
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
neamah al-naffakh
il 24 Mag 2017
Commentato: Star Strider
il 25 Mag 2017
I have data from the accelerometer sensor and this is an example of my signal
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164419/image.png)
the first step i have divided the data into segment (each segment have 300 values) so in total i have 10 segments.
I need to find the frequency of each segment, which means i would have 10 values (each value represent the frequency of specific segment) .
could you please help me to determine the frequency and store them in an array?
Regards.
0 Commenti
Risposta accettata
Star Strider
il 24 Mag 2017
11 Commenti
Star Strider
il 25 Mag 2017
The frequencies increase because of the way the arguments to findpeaks are calculated.
See if this does what you want:
D = load('neamah al-naffakh matlab.mat');
Acc_X_Segments_256 = D.Acc_X_Segments_256;
Fs = 30; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency
L = 300; % Length Of Data Vectors
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
for k1 = 1:length(Acc_X_Segments_256)
SegmentData = Acc_X_Segments_256{k1}; % Data For Each Segment
SegmentData_mc = SegmentData-mean(SegmentData);
FTdata = fft(SegmentData_mc)/L; % Fourier Transform
FTdata_vector = abs(FTdata(Iv))*2; % Fourier Transform Vector For ‘plot’ & ‘findpeaks’
MaxPk = min([0.2 max(FTdata_vector)*0.99]);
[PeakAmplitudes{k1}, Frequencies{k1}] = findpeaks(FTdata_vector, Fv, 'MinPeakHeight',MaxPk);
if isempty(PeakAmplitudes{k1})
figure(k1)
plot(Fv, FTdata_vector)
grid
end
end
I subtracted the mean from the data before taking the Fourier transform in order for the 0 Hz signal not to be the predominant peak.
The outputs of findpeaks are stored as cell arrays. For information on working with cell arrays, see the documentation on Cell Arrays (link) if you are not familiar with them.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!