Mean and Median Frequency
이전 댓글 표시
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
KALYAN ACHARJYA
2021년 1월 2일
편집: KALYAN ACHARJYA
2021년 1월 2일
EMG_Filtered2segment ??
ZackyAs
2021년 1월 2일
Image Analyst
2021년 1월 2일
How are we supposed to run these lines when you're not supplying us wtih the files?
L=importdata('BRYAN 1ST HALF (1).txt');
T1_10rm_BS_2=importdata('BRYAN 2ND HALF.txt');
ZackyAs
2021년 1월 2일
Image Analyst
2021년 1월 2일
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?
ZackyAs
2021년 1월 2일
답변 (1개)
Star Strider
2021년 1월 2일
0 개 추천
댓글 수: 2
ZackyAs
2021년 1월 2일
Star Strider
2021년 1월 2일
I only suggested them to you.
Use whatever works to do what you want.
카테고리
도움말 센터 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!