# MATLAB: Find peaks in a specific portion of data

find data peaksfind peaksfindpeaksremove artifactsremove peaks

Hello,
I have sets of data with a group of artifacts at the begging and end (see below – ignore the middle artifact): I need to isolate the portions of the data with the start/end artifiacts as I'll be removing them. Right now I'm identifying the group of artifcats manually by literally zooming in on them and seeing exactly which point they start and end:
``xlim_br_start = [1000 9000];xlim_br_end = [320000 350000];``
But because I have multiple sets of data like this that have these start/end artifacts but, with slightly varying start/end times, I would like to automate the process of isolating them so I can remove them.
Does someone know how to go about doing this? Any advice is appreciated.
Thanks in avance.

``% Create datay = rand(1,10000) ./ 50; y(randi(200,1,30)+300) = rand(1,30)/2 + 0.5; x = linspace(0, 3.5, 10000); threshold = 0.2; % Plot datafiguresubplot(2,1,1)plot(x,y, 'b-')% Mark thresholdhold onplot(xlim,threshold*[1,1], 'r-')%identify outliersisOut = y > threshold; % Plot data without outlierssubplot(2,1,2)plot(x(~isOut), y(~isOut), 'b-')``
``%Same as my example above except...%identify outliersisOut = isoutlier(y);``