# How to calculate the Frequency Centroid and Mean square frequency for the attached dataset in MATLAB?

18 visualizzazioni (ultimi 30 giorni)
PRAMOD A il 27 Gen 2022
Risposto: Rishabh Singh il 8 Feb 2022
Hi all,
Please explain to me how to calculate the Frequency centroid and Mean square frequency for the attached dataset in MATLAB
My dataset is long having more than 50,000 rows and two columns(time domain and Fx values)
The data set is attached to this question.
In the dataset first column indicates the time in seconds and the second column indicates force in newton.
So, basically, it's a time-domain signal and needs to convert to frequency domain for the calculation of Frequency centroid and Mean square frequency.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Rishabh Singh il 8 Feb 2022
Hi,
You can refer to following answer, explaining how to perform "FFT" on discrete data.
t = table2array(data(:,1)); % Time Vector
s = table2array(data(:,2)); % Signal Vector
Ts = mean(diff(t)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(t); % Signal Length (Number Of Samples)
FTs = fft(s - mean(s))/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTs(Iv))*2)
grid
xlabel('Frequency')
ylabel('Amplitude')
Please refer to the documentation of "spectralCentroid" for frequency centroid calculation.
centroid = spectralCentroid(abs(FTs(Iv))*2 , Fv,'SpectrunType' , 'magnitude');
Hope this helps.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Spectral Measurements in Help Center e File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by