Clear Filters
Clear Filters

Kindly review my results on applying FFT for a non-periodic EMG signal.

4 views (last 30 days)
Hello.
I'm trying to do a performance analysis of hand muscles for my capstone project, and I'm using EMG sensor to help me. The process is to obtain the time domain values and convert them into frequency domain which I need for the next step of the performance analysis.
I'm using MyoWare EMG sensor which gives a signal that is already filterd, rectified and amplified.
The sensor has three chennels and I obtained the signals through each one of them. And then, I plotted the time domain of them. And as you can see, the signals are not periodic.
Then I applyed FFT function on them and plotted the frequency domain as well.
And this is my full code:
clear; clc; clf;
t = 0:1/100:10-1/100; % Time vector
a = arduino();
% Preallocate the y array to store data from all channels
num_channels = 3; % Number of channels (A0, A1, A2)
x = zeros(num_channels, length(t));
y = zeros(num_channels, length(t));
for i = 1:length(t)
% Read voltage from each channel
for channel = 0:num_channels-1
x(channel+1, i) = readVoltage(a, ['A' num2str(channel)]);
end
end
% Compute DFT of x
for channel = 1:num_channels
y(channel, :) = fft(x(channel, :));
end
% Magnitude of FFT
m = abs(y);
% Plot time-domain
for channel = 1:num_channels
figure(1);
subplot(num_channels,1,channel);
plot(t, x(channel, :));
xlabel('Time (s)');
ylabel('Voltage');
title(['Time Domain Signal - Channel ' num2str(channel)]);
ax = gca;
ax.XTick = [15 40 60 85];
end
% Phase calculation and plot in the frequency domain
p = unwrap(angle(y)); % Phase
f = (0:length(y)-1)*100/length(y); % Frequency vector
for channel = 1:num_channels
figure(2);
subplot(num_channels,1,channel);
plot(f, p(channel, :)*180/pi);
xlabel('Frequency (Hz)');
ylabel('Phase (degrees)');
title(['Frequency Domain Phase - Channel ' num2str(channel)]);
ax = gca;
ax.XTick = [15 40 60 85];
end
My questions are:
  1. Are my frequency domain graphs correct (Taking into consideration that my original signals are not perodic)? So am I ready to go to the next step?
  2. Is there any advices or adjustment that you think will help me improve my code overall?

Answers (1)

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU on 8 May 2024
Hi sadem,
Your approach using FFT for non-periodic EMG signals is partially correct. FFT assumes periodicity, and the resulting spectrum shows a fundamental frequency and harmonics that might not be present in your EMG signal.
  • Since your EMG signals are non-periodic, consider using alternative methods like "Welch's" method (using "spectrogram" or "pwelch") to obtain a power spectral density (PSD) representation. The PSD reflects the distribution of power across frequencies without assuming periodicity.
Code Improvement Suggestions:
  • Close Arduino connection: Add "clear a" at the end to close the connection to the Arduino board.
  • Error handling: Consider adding error handling for potential issues with reading voltage from the Arduino.
  • Filtering details: If filtering is crucial for your analysis, explicitly mention the filter type and cutoff frequencies used in the preprocessing stage (before applying FFT).
This should clarify your doubts.

Community Treasure Hunt

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

Start Hunting!