an EMG signal code

2 次查看(过去 30 天)
Risso Hasani
Risso Hasani 2012-1-10
回答: nick 2025-4-3
hello all, I'm new here and need your help >.<
I have An Unbiased, Full-rectifed EMG signal... if this signal reaches threshold of 1 it goes ZERO .. else it continues summing until reaching 1 then it resets to zero and so on. Now I could come up with filtration and unbias code... but stuck at the condition and For loop...
Any Help? :)

回答(1 个)

nick
nick 2025-4-3
Hi Risso,
You can iterate over the signal to apply the threshholding logic as shown below:
emg_signal = [0.2, 0.3, 0.4, 0.5, 0.2, 0.7, 0.1, 0.6, 0.3, 0.5, 0.8];
% Initialize variables
threshold = 1;
cumulative_sum = 0;
processed_signal = zeros(size(emg_signal));
% Iterate over each sample in the EMG signal
for i = 1:length(emg_signal)
% Add the current sample to the cumulative sum
cumulative_sum = cumulative_sum + emg_signal(i);
% Check if the cumulative sum reaches the threshold
if cumulative_sum >= threshold
% Reset the cumulative sum
cumulative_sum = 0;
% Set the output to zero
processed_signal(i) = 0;
else
% Otherwise, set the output to the current cumulative sum
processed_signal(i) = cumulative_sum;
end
end
disp(processed_signal);
0.2000 0.5000 0.9000 0 0.2000 0.9000 1.0000 0 0.3000 0.8000 0
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Specialized Power Systems 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by