How to find the centroid of curve ?
14 views (last 30 days)
Show older comments
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 ?
2 Comments
Answers (1)
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);
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!