필터 지우기
필터 지우기

Fitting Data to a Non-Linear Curve

조회 수: 1 (최근 30일)
Andrew Rowe
Andrew Rowe 2019년 12월 8일
답변: Alex Sha 2019년 12월 9일
I have matrix data for x and y and am looking to find an equation that best represents this data. We don't believe it is a polynomial line of best fit so polyfit wouldn't be appropriate. Is there a method for finding the equation for logarithmic or exponential through data?
Here's the data for reference:
x=[0 1 2 3 4 5 6 7 8 9 10]
y=[.0242 0.1940 0.2792 0.2358 0.1386 0.0598 0.0238 0.0090 0.0034 0.0013 0.002]
  댓글 수: 1
Image Analyst
Image Analyst 2019년 12월 8일
Looks like it could either be log-normal, or the sum of two normals. Is there some knowledge you have about the physics of the situation that might lead you to prefer one or the other, or even some other equation? What physical process gave rise to these measurements?
x=[0 1 2 3 4 5 6 7 8 9 10]
y=[.0242 0.1940 0.2792 0.2358 0.1386 0.0598 0.0238 0.0090 0.0034 0.0013 0.002]
plot(x, y, 'bs-');
grid on;
0000 Screenshot.png
I can fit the data to either equation with fitnlm() though with only 10 data points, it will be difficult to definitively state that one is better than the other because the sum of the residuals is less. You'd need many more data points to be more certain which is better.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2019년 12월 8일
One possibility:
x=[0 1 2 3 4 5 6 7 8 9 10];
y=[.0242 0.1940 0.2792 0.2358 0.1386 0.0598 0.0238 0.0090 0.0034 0.0013 0.002];
objfcn = @(b,x) b(1).*x.*exp(b(2).*x);
B0 = [1; -1];
[B,rsdnrm] = fminsearch(@(b) norm(y - objfcn(b,x)), B0);
xv = linspace(min(x), max(x));
figure
plot(x, y, 'pg')
hold on
plot(xv, objfcn(B,xv), '-r')
hold off
grid
text(4.5, 0.22, sprintf('$y(x) = %.3f \\cdot x \\cdot e^{%+0.3f \\cdot x}$',B), 'Interpreter','latex')
xlabel('x')
ylabel('y(x)')
The most accurate model would be one that models the process that created your data.
This model produces:
1Fitting Data to a Non-Linear Curve1Fitting Data to a Non-Linear Curve - 2019 12 07.png

추가 답변 (1개)

Alex Sha
Alex Sha 2019년 12월 9일
If don't care the function type, the follow is one:
y = p1*(p2^x)*(x+p3)^p4;
Root of Mean Square Error (RMSE): 0.0032240913289773
Sum of Squared Residual: 0.000114342413873453
Correlation Coef. (R): 0.999488278914727
R-Square: 0.998976819687923
Adjusted R-Square: 0.998721024609904
Determination Coef. (DC): 0.998955740196223
Chi-Square: 0.00189307571492163
F-Statistic: 2218.55228360604
Parameter Best Estimate
---------- -------------
p1 0.0382808254972641
p2 0.190470576993248
p3 0.932820554835385
p4 4.94812019020198
c240.jpg

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by