Detect main part of a signal
32 次查看(过去 30 天)
显示 更早的评论
Hi, I would like to receive some help about one question:
Need to know how to detect the real signal in an EMG file (as image 1).
Till now, I know how to find the absolute center with this code:
[F, C]=size(D.data);
center=(F-mod(F,2))/2;
x=x(center-1500:center+1500,:);
and then I search results on both sides of that middle point, but as you can see, it doesn't return symetric values (image 2).
How can I add something to that code to detect the interesting area?
Thanks, regards
0 个评论
采纳的回答
Star Strider
2024-11-4,16:14
I usually use the envelope function, usually using the 'peak' option, and then test for the first instance of those (ususlly the upper envelope) exceds a ceertain threshold.
To illustrate —
Fs = 1E+3;
L = 60;
t = linspace(0, Fs*L, Fs*L+1).'/Fs;
EMG = randn(size(t))/10;
N = numel(t((t>=15 & t<=45)));
EMG(t>=15 & t<=45) = randn(N,1);
figure
plot(t, EMG)
grid
xlabel('Time')
ylabel('Amplitude')
title('Original')
[eu,ed] = envelope(EMG, 50, 'peak');
thrshld = max(eu(t>0 & t<5));
sigstart = find(eu >= thrshld*1.5, 1, 'first');
sigend = find(eu >= thrshld*1.5, 1, 'last');
figure
plot(t, EMG, DisplayName="Signal")
hold on
plot(t, eu, '-r', DisplayName="Upper Envelope")
hold off
grid
xline(t([sigstart sigend]), '--k', LineWidth=2, DisplayName="Signal Borders")
xlabel('Time')
ylabel('Amplitude')
title('Original With upper Envelope & Signal Borders')
legend('Location','best')
.
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!