# Find specific points of increase within multiple different data sets

19 views (last 30 days)
pkll201 on 22 May 2024 at 12:25
Commented: Mathieu NOE on 24 May 2024 at 8:45
I am trying to write a function to identify the points as shown on this graph (not ones crossed with red).
However, I can't seem to get it to only identify the start and finish of the increase of data. Most of them are identifying points in between which are not wanted (but not at every point). This is what I have written so far:
function [Lpoints] = findpoints(Ldata)
%Calculate the point of abrupt changes in Ldata
Lchange = ischange(Ldata,'linear','Threshold',500);
%Find indices of changes
Lindices=find(Lchange);
%Calculate change in L between these indices
figure;
plot(Ldata);
xline(Lindices);
Lpoints=Lindices;
I have tried to exclude the central points by adding this (and adjusting the Ldiff>x parameter) to only get the start of the increase but this seems to eliminate the more subtle increases, and it would be preferred to get both points.
Lvalues = Ldata(Lindices);
Ldiff = [0; diff(Lvalues)];
number=Ldiff>40;
Ldiff(number)=NaN;
indices=~isnan(Ldiff);
Lindices2=Lindices(indices);
Lpoints=Lindices2
I have attached a selection of sample data, and it would be ideal to get something that works across the board. I may be taking the wrong approach, so any suggestions of how to go about this would be great!

Mathieu NOE on 22 May 2024 at 15:35
hello
try this... hope it helps - though I did not draw vertical lines but you have to start and ending points coordinates.
I tested the code on the 10 examples data provided
% whos
% Name Size Bytes Class Attributes
%
% example1 1096x1 8768 double
% example10 486x1 3888 double
% example2 1327x1 10616 double
% example3 1116x1 8928 double
% example4 690x1 5520 double
% example5 642x1 5136 double
% example6 720x1 5760 double
% example7 834x1 6672 double
% example8 655x1 5240 double
% example9 790x1 6320 double
data = example1;
% high pass filter the data first
[b,a] = butter(2,0.01,'high');
% find start , end points = positive and negative peaks of the high pass
% filtered data (with islocalmax)
minpeakdist = 50;
locsp = find(tf);
locsn = find(tf);
locsn(locsn>locsp(end)) = []; % remove "start" point wich is now followed by "end" point at the end of the data
% plot
xaxis = 1:numel(data);
plot(xaxis,data,xaxis(locsn),data(locsn),'dk',xaxis(locsp),data(locsp),'dr');
legend('data','start points','end points','Location','NorthEastOutside');
pkll201 on 24 May 2024 at 8:30
That's amazing - works perfectly! Thank you so much :)
Mathieu NOE on 24 May 2024 at 8:45
my pleasure !
have a great day

### Categories

Find more on Multirate Signal Processing in Help Center and File Exchange

R2023b

### Community Treasure Hunt

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

Start Hunting!