Signal processing - difficult. How to extract specific parts of the signal identified via findpeaks?
Show older comments
Hi all,
I have a signal (attached) which is a sensor orientation y during human walking. I have identified certain indices in the signal (attached 'start'', red circles over the signal) and I am extracting parts of the signal between those indices using the code below.
However, I want to discard (ignore) part of the signal between two blue x-es (on the left at the bottom) which is a moment when a person turns around and start walking again. Any idea how to do this?

load 'signal'
load 'start'
%This is how I indetify the indices
% Identify all troughs in data
[all_trough_value,all_trough_location]= findpeaks(-thigh_orient_y, 'MinPeakProminence',7);
all_trough_value = -all_trough_value;
% Identify main trough (i.e. main peaks with a prominence of at least 10)
[main_trough_value,main_trough_location]= findpeaks(thigh_orient_y,'MinPeakProminence',15);
% Identify first local minima before main through (start of the cycle)
counter = 0;
for i = 1:length(main_trough_location)
index = find(all_trough_location < main_trough_location(i),1,'last');
if isempty(index)
continue
end
counter = counter + 1;
start_location(counter) = all_trough_location(index); % find start location
start_value(counter) = all_trough_value(index); % find start value
end
%Settings
T_or_y = thigh_orient_y;
a = start_location;
n = length(a)-1;
T_or_y_cycle = cell(n,1) ;
%Fill in cells with signal between the indices
for i = 1:n
T_or_y_cycle{i} = T_or_y(a(i):a(i+1)) ;
end
%Plot all over one figure
figure;
hold on
for i = 1:length(T_or_y_cycle)
plot(T_or_y_cycle{i},'r') ;
title('RThigh orientation Y'); xlabel('% of movement cycle'); ylabel('degrees')
box off; axis tight;
end
Ideally, the solution should work also for walking on the stairs (walk up twice and walk down twice)/ attached 'signal 2' and 'start2'

Accepted Answer
More Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!