247 views (last 30 days)

Geoff
on 3 May 2012

You can use diff or gradient.

Decide what minimum rate of change is acceptable:

tolerance = 1e-4;

And then to find the point of interest:

index = find( abs(diff(x)) > tolerance )

However, this is going to find ALL points that exceed your tolerance. I don't know what your data is, but if you say it accelerates, then every point after the turning point is going to be returned. Also, unless there is a theoretical reason behind your 'small changes', you might need to detect the tolerance. That's always more fiddly.

Another way to go about this is to detect a 'baseline' and remove it from your data. It might not be relevant to you... I've used this to analyse qPCR experiments for gene research. We had sigmoid-like curves where the initial part of the curve was linear. I had to detect that linear section, find a regression line through it, and subtract that line from the data. It might not be relevant to you. The theory behind this is to remove from the data any constant change that is proven to exist and must be corrected.

How many turning points do you expect in each vector, or is this unknown? What does the data look like?

Vahid
on 12 Nov 2015

Ulises Sosa
on 27 Nov 2018

Hello,

I have a similar situation. I want to find baseline points for a current(um) versus potential(V) graph.I am too interested in the method that you are using for your qPCR experiments.Thank you!

Sign in to comment.

Richard Brown
on 3 May 2012

Edited: Richard Brown
on 3 Nov 2012

Why don't you look for local maxima of curvature? This way you don't have to define any subjective tolerances. You may need to smooth your data first to make sure the finite difference derivative approximations work cleanly though.

To keep it simple, I'll assume your independent variable is evenly spaced and use a simple example (decaying exponential). We want to find the "knee"

dt = 0.01;

t = 0:dt:1;

y = exp(-10*t);

Compute first and second derivatives by finite differencing (centred)

yp = nan(size(y));

ypp = nan(size(y));

yp(2:end-1) = (y(3:end) - y(1:end-2))/(2*dt);

ypp(2:end-1) = (y(3:end) + y(1:end-2) - 2*y(2:end-1)) / (dt^2);

Compute the curvature

k = abs(ypp) ./ (1 + yp.^2).^1.5

Find the maximum and plot it on the curve. You could easily adapt this to find local maxima of k, etc.

[kmax, idx] = max(k);

plot(t, y, 'b', t(idx), y(idx), 'ro')

Also of interest to plot the curvature

figure()

plot(t, k)

edit: fixed wrong indices in plot command

Sargondjani
on 1 May 2012

take the difference between each two points in the vector (use 'diff')

evaluate if these numbers 'grow faster'. Im not sure what your criterium is here. If you specify that, somebody might be able to help you further

Sargondjani
on 2 May 2012

my problem was that i dont know what your definition of acceleration is...

i mean, you say that the differences between points is too small to directly tell when there is change. this implies that some points are numerically EXACTLY the same and some are not. that means there is some sort of acceleration before your turning point as well

so you need to be more specific about what acceleration is...

Sign in to comment.

Masoud Hosseiny
on 29 Jun 2018

Hi. you can calculate the differential of data set and plot it at the same time.

Kriti Modi
on 3 Jul 2018

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/37103-finding-turning-points-of-a-dataset#comment_77105

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/37103-finding-turning-points-of-a-dataset#comment_77105

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/37103-finding-turning-points-of-a-dataset#comment_77420

⋮## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/37103-finding-turning-points-of-a-dataset#comment_77420

Sign in to comment.