how to find slop of a curve at a point?

5 次查看(过去 30 天)
amir
amir 2014-11-21
回答: arich82 2014-11-21
i have to series of data:
x=[0.01324, 0.152784,1.426024,14.76958,147.6958,1527.888,15229.85]
y=[0.0000025,0.0000075,0.000025,0.000075,0.00025,0.0008,.0025]
I plot these points then I have a curve I want to find slope at each points of this curve(points were in data) I don't know how? please help me

回答(1 个)

arich82
arich82 2014-11-21
There are several ways to compute the derivative numerically, cf.
help diff
but this can be noisy, and isn't terribly precise for data with large gaps. If this is truly data, you might want to look at the loglog plot
loglog(x, y, '.')
You'll see it's very nearly linear in log-log.
Assuming you're not using any toolboxes, you can look at
help ployfit
to perform a regression on log(x), log(y), or use the backslash operator to find a linear fit.
x=[0.01324, 0.152784,1.426024,14.76958,147.6958,1527.888,15229.85];
y=[0.0000025,0.0000075,0.000025,0.000075,0.00025,0.0008,.0025];
n = numel(x);
X = log(x(:));
Y = log(y(:));
M = [ones(n, 1), X]\Y;
C = exp(M(1));
b = M(2);
loglog(x, y, '.', x, C*x.^b);
Now that you have a good fit for your data, use the expression C*x.^b to interpolate it, and analytically compute your derivative for any value of x.
This isn't exactly what you asked, so let me know if this helps (or if you truly prefer a numerical derivative, and are struggling with diff).
--Andy

类别

Help CenterFile Exchange 中查找有关 Curve Fitting Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by