Ono
Ono

Reputation: 1357

matlab curve fitting with sub-polynomial

I am wondering how do I fit three points x = ([0.42 0.64 0.96]) and y = ([4.2 5.1 6.0]) with y = k*x^(0.88)?

I tried [p,S,mu] = polyfit(x,y,0.88); but MATLAB says only power in integer numbers are accepted. Thanks.

EDIT:

The idea is I know these three points should follow the curve based on some theory, so I want to plot it to convince myself. Also, I'd like to do curve fitting because I don't know what k is.

Upvotes: 0

Views: 84

Answers (2)

jolo
jolo

Reputation: 423

What about lsqnonlin ?

You could try

model = @(x,k) (k*x.^0.88);
resVec = @(k) (y(:) - model(x(:),k));
k_start = 1;
k_opt = lsqnonlin(resVec,k_start);

Upvotes: 2

yoh.lej
yoh.lej

Reputation: 1104

If you're OK with adding a constant to your model you can do:

[p,S,mu] = polyfit(x.^(0.88),y,1);

then you'll have y approximated by p(2)*x.^(0.88)+p(1) (minimizing the sum of the squares of the errors)

Upvotes: 2

Related Questions