caculate frequency from signal data

17 visualizaciones (últimos 30 días)
neamah al-naffakh
neamah al-naffakh el 24 de Mayo de 2017
Comentada: Star Strider el 25 de Mayo de 2017
I have data from the accelerometer sensor and this is an example of my signal
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.

Respuesta aceptada

Star Strider
Star Strider el 24 de Mayo de 2017
Use the fft (link) function to transform your time-domain data to the frequency domain.
Use the findpeaks (link) function to find the dominant peaks for each segment and their frequencies.
  11 comentarios
neamah al-naffakh
neamah al-naffakh el 25 de Mayo de 2017
dear Sir,
why the frequencies value for each segment are arranged from small value to big value?
i was thinking they will be randomly arranged? please see the attached pic!
let's make it easy. i just want to calculte the frequency for each segment and store it in an array!
forget about the index and high and low frequencies
Star Strider
Star Strider el 25 de Mayo de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by