# fitting to a power function with an additional constant

조회 수: 1(최근 30일)
friet 2018년 2월 6일
댓글: Walter Roberson 2018년 2월 6일
Hello Matlab! I have this dataponits t and y. I want to fit those data points to a function y=a(t+c)^b, and get the parameters a,c and b.I have tried below, but not converging. Can anyone suggest me Thanks GH
close all
clear all
clc
t=[0.097
0.477
0.934
4.835
15.590
46.645
69.371
100.709
165.249
277.846
382.978
1000.64
1519.83
1991.60
2544.96
3023.40
3589.94
4159.93
4473.43
5186.36
6316.71
7134.15
9125.71
10571.90
12565.82
14916.64
16859.92
];
y=[20.96
21.33
20.77
20.96
21.14
21.33
20.24
19.71
17.90
15.98
14.51
10.05
8.37
7.40
6.49
6.05
5.54
5.17
4.82
4.57
4.26
3.87
3.52
3.25
3.08
2.80
2.61
];
loglog(t,y,'o')
F = @(x,xdata)x(1)*(x(2)+xdata).^x(3);
x0 = [80 -0.1 130];
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,t,y)
hold on
plot(t,F(x,t))
hold off

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

### 답변(1개)

Walter Roberson 2018년 2월 6일
You used an unconstrained curve fitting, which did a trial run with some values that were invalid for your function.
Your x0 is not especially close to the best parameters, which are approximately 851.271574244121 -0.604937228501513 436.783547500979
##### 댓글 수: 4표시숨기기 이전 댓글 수: 3
Walter Roberson 2018년 2월 6일
You have x(2)+xdata, where xdata is t. min(t) is 0.097 so if your trial x(2) is less than -0.097 then you would get a negative value for x(2)-min(t), and you would then try to raise that negative to a floating point power. You thus need a constraint that x(2) >-min(t) to avoid that negative raised to a floating point.
I will need to investigate further as to why I did not encounter this problem in my own tests.

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

### 범주

Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by