- #1
EE_ROB
- 2
- 0
Homework Statement
I have the task of finding the first peak (percussion peak) per each period of a ICP signal. I was told to filter the signal to get rid of some noise and a dc offset, find the percussion peak indicies and then plot those back onto the original signal. I am unable to only plot the first peak, my code plots both peaks. I am not sure why my code is not differentiating between the indicies of relavence. Any help with the code below would help,
Homework Equations
The Attempt at a Solution
clc; close all;
load icpComposite
x = icpcomposite;
k = 1:length(x);
%% filtering
b = fir1(200,30/(fs/2));
y1 = filtfilt(b,1,x);
%% Detrending
b = fir1(300,0.5/(fs/2),'high');
y2 = filtfilt(b,1,y1);
figure;
plot(y2);
%% Peak Detection
L = 1:length(y2);
[ymax,imax] = extrema(y2);
figure;
plot(L,y2,L(imax),ymax,'r.');
%% Error Correction
imd = diff(imax);
imdm = median(imd);
mdt = 0.5*imdm;
mdind = find(imdm<mdt);
mdind = mdind+1;
imax(mdind) = 0;
imax = unique(imax);
figure;
plot(k,x,imax,x(imax),'r.');