Mean and Median Frequency
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I am a newbie in doing coding for mean and median frequency. first of all, i cut the signal before applying the fft. then i apply window hamming to fft then i create coding for mean and median frequency. i want to extract the value for mean and median but it gives output columns zero. unfortunately i couldnt detect the problem regarding my coding. can someone help me please?
b=EMG_Filtered2segment; %signal data
fs =1000; %sampling frequency
cut=1*fs; %cut signal every second
Window=hamming(cut);
L= 300
id1=1
for i = 1:length(b)/cut
slice=b(1+(i-1)*cut: i*cut);
signal(:,i)=slice;
Ls=length(slice);
Nfftslice=2^nextpow2(Ls);
signalwin=Window.*slice;
FFT=fft(signalwin);
absFFT=abs(FFT);
FFTonesided=2*absFFT(1:Ls/2+1); %double amplitude, one side
FFTonesided(1)=FFTonesided(1)/2; %DC part is not doubled
Hspec=spectrum.welch('Hamming',500,25);
hspd=psd(Hspec,slice,'NFFT',Nfftslice,'Fs',fs);
Pw = hpsd.Data;
Fw=FFTonesided;
PW=cumsum(Fw);
Pwdiv2=median(PW);
Fs=1000;
Freq= Fs*(0:(Ls/2))/Ls;
end
%MEAN AND MEDIAN%
% a=find(FFTonesided(:,1));
for t=1:length(b)/cut
meanPSD(:,i) = sum(Freq.*FFTonesided) / sum(FFTonesided);
OverHalfIdx(:,i) = find(PW>=Pwdiv2,1,'first');
UnderHalfIdx(:,i)= find(PW<=Pwdiv2,1,'last');
MedianPSD(:,i) = (Freq(OverHalfIdx(:,i))+Freq(UnderHalfIdx(:,i)))/2
end
6 Commenti
Image Analyst
il 2 Gen 2021
So you have a couple of signals, and there are a bunch of frequencies, and for each frequency there is a relative power at that frequency.
What do you mean by the mean and median frequency? Do you just want the half way frequency between 0 and the maximum frequency? Or do you want the mean weighted by the power at each frequency?
Risposte (1)
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!