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);
Hope this helps.
