How do I omit a range of points from line?

4 visualizzazioni (ultimi 30 giorni)
Fue Xiong
Fue Xiong il 30 Mar 2022
Modificato: Fue Xiong il 1 Apr 2022
% MATLAB Code
function [dMean, dMax, dMin] = EMGFilter6(EMG)
EMG_2 = EMG;
t = EMG_2(:,1); % time
x = EMG_2(:,2); % signal
d = abs(x);
windowSize = 1000;
b = (1/windowSize)*ones(1,windowSize);
a = 1;
dMean = mean(d);
dMax = max(d);
dMin = min(d);
j = 0.01*dMean;
p = 'concussion';
l = 'no concussion';
y = filter(b,a,d);
for k = i:y
plot(t,d,'color','r')
hold on
plot(t,y,'color','b')
legend('Input Data','Filtered Data')
end
for g = i:y
if g>j
disp(l)
elseif g<j
disp(p)
elseif g == j
disp(l)
end
end
end
% Hello, I'm given a data set of EMG signals. I created a running average mean line for the signal defined by variable "y". I want to omit a range of points from the beginning of the average mean line y so that my running average mean line doesn't start at zero.

Risposte (1)

Voss
Voss il 30 Mar 2022
I'm not sure if this is what you want, but here's how you can remove data before t = 1, for instance:
S = load('data.mat');
EMGFilter6(S.Trial1);
function [dMean, dMax, dMin] = EMGFilter6(EMG)
EMG_2 = EMG;
t = EMG_2(:,1); % time
x = EMG_2(:,2); % signal
% remove t and x before t = 1:
idx_to_remove = t < 1;
t(idx_to_remove) = [];
x(idx_to_remove) = [];
d = abs(x);
windowSize = 1000;
b = (1/windowSize)*ones(1,windowSize);
a = 1;
dMean = mean(d);
dMax = max(d);
dMin = min(d);
% j = 0.01*dMean;
% p = 'concussion';
% l = 'no concussion';
y = filter(b,a,d);
% for k = i:y
% plot(t,d,'color','r')
plot(EMG_2(:,1),abs(EMG_2(:,2)),'r') % plot the entire data
hold on
plot(t,y,'color','b')
legend('Input Data','Filtered Data')
% end
% for g = i:y
% if g>j
% disp(l)
% elseif g<j
% disp(p)
% elseif g == j
% disp(l)
% end
% end
end
  1 Commento
Fue Xiong
Fue Xiong il 1 Apr 2022
Modificato: Fue Xiong il 1 Apr 2022
Sorry, I technically don't want to remove the values from the beginning of the line. I want to in a way be able to iterate through each value along that average mean line y, but skipping say the first 50 values at the beginning of the line. This is because what I am trying to do is detect a drop in the average mean line y when it crosses the threshold "j" in this case. But if the starting average mean line y always start at a value of 0, it will always present itself in the elseif case of "concussion".

Accedi per commentare.

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by