Why does findchangepts doesn't work right?

9 views (last 30 days)
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
vl = bsxfun(@times, ones(numel(lpt), 2), [min(Ch9) max(Ch9)]); % Create Vertical Lines For ‘figure(1)’
plot(tv, Ch9)
hold on
plot([tv(lpt),tv(lpt)]', vl', '-r', 'LineWidth',1.5)
hold off
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 on 17 Sep 2018
Related Q

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);

Community Treasure Hunt

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

Start Hunting!