how to find the inflection point of a curve in matlab
106 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
cloudy snow
le 12 Juil 2016
Commenté : Star Strider
le 15 Juil 2016
hi....does anyone know how to find the inflection point of a curve in matlab? any suggestion is highly appreciated..
4 commentaires
Image Analyst
le 15 Juil 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
le 15 Juil 2016
‘cloudy’ included it in an Answer. I attached it (as ‘cloudy snow 30ppmGE.xlsx’) to my Comment to my Answer.
Réponse acceptée
Star Strider
le 12 Juil 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.
8 commentaires
Star Strider
le 15 Juil 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
figure(1)
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
grid
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 ‘*’.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!