MATLAB Answers

how to find the inflection point of a curve in matlab

208 views (last 30 days)
cloudy snow
cloudy snow on 12 Jul 2016
Commented: Star Strider on 15 Jul 2016
hi....does anyone know how to find the inflection point of a curve in matlab? any suggestion is highly appreciated..


Show 1 older comment
cloudy snow
cloudy snow on 13 Jul 2016
I'm very new to Matlab. I've some data about copper foil that are lists of points of potential(X) and current (Y) in excel . The purpose is to draw curves and find the inflection points of them..After finding the inflection points, the value of potential that can be used to get better quality of current will be defined for future use. I plotted the curves , but i don't know how to find the inflection points. Thank you.
Image Analyst
Image Analyst on 15 Jul 2016
What Robert is asking is if you want to find the point off the digitized numerical data (array elements), or if you fitted your data to some kind of analytical equation, like a Boltzmann or a Cauchy curve or something like that. If you have parameters of a theoretical equation, you can sometime just get the inflection point from the mathematical equation of the second derivative of the curve.
Star Strider
Star Strider on 15 Jul 2016
‘cloudy’ included it in an Answer. I attached it (as ‘cloudy snow 30ppmGE.xlsx’) to my Comment to my Answer.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 12 Jul 2016
If your curve are data (not calculated by a function) I would use the gradient function to calculate the derivative. To find the zero-crossing of the derivative, you can either use a threshold test, or if appropriate for your derivative, the interp1 function.


Show 5 older comments
cloudy snow
cloudy snow on 15 Jul 2016
Sir, the figure I want is as shown in attached photo...I have many data files like I've sent to you...I did as your suggestion to use gradient and interp1 functions ... but I have got error message for that one..
cloudy snow
cloudy snow on 15 Jul 2016
I'm sorry...I think there was no photo in previous is the photo...
Star Strider
Star Strider on 15 Jul 2016
The sign change does make a difference, in addition to which I now know the correct independent and dependent variables. (See: Draw tangent line in step response ?)
I have no idea how you chose that one point. I ran my previous analysis in the link with your data, and I still cannot identify any true inflection points that corresponds to that point. I did this even after using polyfit to smooth out the noise. (I got an acceptable fit, but this did not permit the identification of the point you plotted.)
This is the best I can do:
[d,s,r] = xlsread('cloudy snow 30ppmGE.xlsx');
I = -d(:,1); % Current
E = d(:,2); % Potential
t = E(E<=0);
y = I(E<=0);
[b,S,mu] = polyfit(t, y, 6);
fy = polyval(b,t,S,mu);
y = fy;
d1y = gradient(y,t); % Numerical Derivative
d2y = gradient(d1y,t); % Numerical Second Derivative
t_infl = interp1(d1y, t, max(d1y)); % Find ‘t’ At Maximum Of First Derivative
y_infl = interp1(t, y, t_infl); % Find ‘y’ At Maximum Of First Derivative
slope = interp1(t, d1y, t_infl); % Slope Defined Here As Maximum Of First Derivative
intcpt = y_infl - slope*t_infl; % Calculate Intercept
tngt = slope*t + intcpt; % Calculate Tangent Line
plot(t, y)
hold on
plot(t, fy)
plot(t, d1y, '-.m', t, d2y, '--c') % Plot Derivatives (Optional)
plot(t, tngt, '-r', 'LineWidth',1) % Plot Tangent Line
plot(t_infl, y_infl, 'bp') % Plot Maximum Slope
hold off
legend('y(t)', 'y(t) Fit', 'dy/dt', 'd^2y/dt^2', 'Tangent', 'Location','E')
axis([xlim min(min(y),intcpt) ceil(max(y))])
Your data do not otherwise have anything that I can identify as an inflection point. If you have a mathematical model of the process that produced your data that you can fit to it using nonlinear regression techniques, that could provide a way to calculate the inflection points. I cannot do it from your data and get any point in the region of the red ‘*’.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by