Find flat regions in a signal above origin (time series data)
Show older comments
Hi all, I would like to detect flat regions in a time series data above the origin. For your reference I have attached a figure and highlighted the region of interest in green color. I have also included the sample data for the same.

I have tried the following code and got the below figure, where it identifes too many flat regions and I dont know how to adjust it to get the above results. Any help in this regard is highly appreciated.
load data.mat;
x=1:numel(data);
y=data;
z = y;
thresh = 0.05; % height threshold
% find peaks
[pks,locs] = findpeaks(z,'MinPeakProminence',thresh);
% remove signal noise between peaks
for ii = 1:length(locs)-1
zz = z(locs(ii)+1:locs(ii+1)-1);
zz(abs(zz) < thresh) = 0;
z(locs(ii)+1:locs(ii+1)-1) = zz;
end
% plot
plot(x,y);
hold on
plot(x,z);
plot(x(locs),pks,'og');
legend('original signal','modified signal','peaks')
Accepted Answer
More Answers (0)
Categories
Find more on Spectral Measurements 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!
