FFT of EMG Signal

I am trying to obtain the FFT of an EMG Signal, I have already done some other type of processing, including; removing DC Offset, Rectification and Signal Envelope, however I am stuck in the FFT part ? Any help would be appreciated ..
Attached the Code and Photo of current situation can be found.

3 Comments

dpb
dpb on 22 Oct 2017
"I am stuck in the FFT part"
For what working definition of "stuck", pray tell?
Karl Rueth
Karl Rueth on 23 Oct 2017
For some reason, the final result, isn't the required signal.
What "final result", there's no FFT uncommented in the sample code; the result will be what it shall be; you can't really "require" anything.
You don't even say what your desired result is that you're looking for, specifically, what are we, mind-readers?
Look at the example at
doc fft
for example of doing PSD via FFT for pointers.

Sign in to comment.

Answers (3)

Star Strider
Star Strider on 22 Oct 2017

1 vote

See the documentation on fft (link).
Luc Dransfeld
Luc Dransfeld on 8 Jan 2018

0 votes

If you follow the FFT documentation from Matlab, you should be able to get there. Maybe though, you should set your plot window differently, as motion artifacts can contain a power that is proportionately way bigger that the rest of the EMG-frequencies resulting that you will only visibly see the motion artifacts. You can always use matlab function: periodogram, which basically gets you the logarithm from the power, expressed in dB.
Trishna Sah
Trishna Sah on 23 Jan 2019
Edited: Trishna Sah on 23 Jan 2019
This is using your variables in the fft doc by Matlab
%fft plot for emg4
Fs=1000;
L=length(emg4);
t=L/Fs;
x=emg4;
Y = fft(x);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Frequency Spectrum Plot')
xlabel('f (Hz)')
ylabel('|P1(f)|')
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')

5 Comments

Hi Trishna,
could you describe what you do with P1 and P2 and why you do this?
Also what unit is the Y-Axis? It should be the number of signals at the particular frequency, right? How come, I get values of 0.12 at the Y-Axis?
Cheers
dpb
dpb on 13 Nov 2020
P2 is two-sided (-Fmax - Fmax) PSD.
P1 is one-sided (0:Fmax) PSD
Since the total energy is distributed over the entire P2, P1 is then normalized to conserve energy by doubling all components except DC and Fmax which are unique and full-valued in P2.
This normalization produces peak values that match the time series magnitude at the given frequency -- it will return 1.0 for a base sin() input of a frequency that matches the bin spacing of the FFT precisely, otherwise one will have to integrate (sum) over the bins containing energy around the input frequency to get the precise total.
This is illustrated by the example in doc fft from which the above code was extracted.
The comment about "number of signals" appears to indicate some confusion about what a PSD represents. As the example shows, it returns the magnitude (or energy by alternate scaling) of the input signal at the given frequencies. It isn't clear what you expected to have gotten...
Thanks for the reply - got you so far. So when fft-ing an EMG signal, the Y-axis in your plot would be Volts (or the respective original signal unit), right? If I wanted to convert that into dB, I would have to 20*log10 the absolut fft signal - is that correct?
dpb
dpb on 15 Nov 2020
Ayup.
Units of x axis and y axis after abs(fft)?

Sign in to comment.

Asked:

on 22 Oct 2017

Commented:

on 28 Dec 2021

Community Treasure Hunt

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

Start Hunting!