Why does findchangepts doesn't work right?

5 views (last 30 days)
Stwiwi
Stwiwi on 17 Sep 2018
Edited: Greg Dionne on 17 Sep 2018
Hey guys, For the attached data file i use the following code so i can find the areas for each of the four separate waves:
D = load('008a_100Hz.mat');
Ch9 = D.Channel_9_Data;
tv = D.Channel_1_Data; % Time Vector
[lpt,rsd] = findchangepts(Ch9, 'Statistic','rms', 'MaxNumChanges',8);
for k1 = 1:2:numel(lpt)-1
sig_seg{(k1+1)/2,1} = Ch9(lpt(k1):lpt(k1+1)); % Signal Values At Each Segment
sig_seg{(k1+1)/2,2} = lpt(k1):lpt(k1+1); % Index Range
end
vl = bsxfun(@times, ones(numel(lpt), 2), [min(Ch9) max(Ch9)]); % Create Vertical Lines For ‘figure(1)’
figure(1)
plot(tv, Ch9)
hold on
plot([tv(lpt),tv(lpt)]', vl', '-r', 'LineWidth',1.5)
hold off
grid
With the code I get sth. like this:
The second vertical line should be on the right of the first waves. Any ideas how that might work? Thanks people:)
  1 Comment
jonas
jonas on 17 Sep 2018
Related Q
https://se.mathworks.com/matlabcentral/answers/418641-how-to-create-plots-for-special-areas-of-an-array

Sign in to comment.

Answers (1)

Greg Dionne
Greg Dionne on 17 Sep 2018
Edited: Greg Dionne on 17 Sep 2018
If you have R2016b or later try:
Fs = 100;
[sst,f] = fsst(Ch9,Fs,kaiser(512,10));
fridge = tfridge(sst,f,10,'NumRidges',1);
findchangepts(fridge,'Statistic','mean','MaxNumChanges',8)

Community Treasure Hunt

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

Start Hunting!