how to find slop of a curve at a point?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!