frequency-time of EMG
Afficher commentaires plus anciens
I am trying to use Matlab to find the median frequency with respect to time of an EMG signal.
B = xlsread('C:/Users//Desktop/fatigue_20.xlsx');
Fe=800;
A = B(0.1e4:8.2e5, :);
N=length(A);
t=0:1/Fe:(N/Fe)-1/Fe;
psdest = psd(spectrum.periodogram,A_si,'Fs',800,'NFFT',N);
normcumsumpsd = cumsum(psdest.Data)./sum(psdest.Data);
Ind = find(normcumsumpsd <=0.5,1,'last');
Median frequency=psdest.Frequencies(Ind)
but now how can i build the relation between the median frequency and the time?
Réponse acceptée
Plus de réponses (3)
Wayne King
le 28 Juin 2013
Modifié(e) : Wayne King
le 28 Juin 2013
Here you go:
Fs = 1000;
t = 0:1/Fs:5;
x = 2*cos(2*pi*100*t).*(t<1)+3*cos(2*pi*200*t).*(t>1 & t<2)+1.5*cos(2*pi*150*t).*(t>2 & t<3)+2*sin(2*pi*50*t-pi/4).*(t>4)+randn(size(t));
window = 100;
[S,F,T,P] = spectrogram(x,window,window/2,window,Fs);
for nn = 1:size(P,2)
normcumsumpsd = cumsum(P(:,nn))./sum(P(:,nn));
Ind = find(normcumsumpsd <=0.5,1,'last');
medianfreqs(nn) = F(Ind);
end
plot(T,medianfreqs);
xlabel('Time (seconds)');
ylabel('Median Frequency (Hz)');
You see that the median frequency is time dependent
3 commentaires
li
le 28 Juin 2013
Wayne King
le 28 Juin 2013
what is the dimension of your signal, do
>>whos x
li
le 28 Juin 2013
Wayne King
le 28 Juin 2013
If I just substitute a vector of random noise the same size as your input
Fs = 800;
x = randn(841700,1);
window = 100;
[S,F,T,P] = spectrogram(x,window,window/2,window,Fs);
for nn = 1:size(P,2)
normcumsumpsd = cumsum(P(:,nn))./sum(P(:,nn));
Ind = find(normcumsumpsd <=0.5,1,'last');
medianfreqs(nn) = F(Ind);
end
plot(T,medianfreqs);
xlabel('Time (seconds)');
ylabel('Median Frequency (Hz)');
The above works fine for me. Of course, you need to make sure the window length makes sense for your data.
1 commentaire
li
le 28 Juin 2013
CHOW KHUEN CHAN
le 3 Juil 2017
0 votes
Hi there, do you know how to edit and compute the median of the segments. Any idea?
Catégories
En savoir plus sur Spectral Measurements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!