How to find the centroid of curve ?

47 views (last 30 days)
Sambit Supriya Dash
Sambit Supriya Dash on 27 Sep 2021
Answered: Image Analyst on 27 Sep 2021
I have a curve fitted to a given data and got this curve(x).
curve(x) = a*exp(b*x) + c*exp(d*x)
Coefficients (with 95% confidence bounds):
a = -5458 (-6549, -4368)
b = 0.1531 (0.1456, 0.1606)
c = -2085 (-3172, -997.9)
d = 0.2584 (0.2182, 0.2986)
How to find the (x,y) of the centroid of the curve (in any curve) in MATLAB ?

Answers (1)

Image Analyst
Image Analyst on 27 Sep 2021
Try this:
% Coefficients (with 95% confidence bounds):
a = -5458 % (-6549, -4368)
b = 0.1531 % (0.1456, 0.1606)
c = -2085 % (-3172, -997.9)
d = 0.2584 % (0.2182, 0.2986)
% Declare the range over which you want to evaluate the curve.
x = linspace(-10, 10, 2000);
% Get the y values for the curve.
curve = a*exp(b*x) + c*exp(d*x)
% Plot the curve.
plot(x, curve, 'b-', 'LineWidth', 2);
grid on;
fontSize = 20;
title('a*exp(b*x) + c*exp(d*x)', 'FontSize', fontSize);
xlabel('x', 'FontSize', fontSize);
ylabel('curve', 'FontSize', fontSize);
% Find mean.
meanx = mean(x)
meany = mean(curve);
% Plot mean on the graph.
hold on;
plot(meanx, meany, 'r+', 'LineWidth', 2, 'MarkerSize', 40);

Community Treasure Hunt

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

Start Hunting!