Reputation: 1
I am trying to find a fitting curve as described below. MATLAB's polyfit
does not work in my case.
Known parameters: x
and y
, and the fitting curve y_fit = a * (x_fit) .^ n
(here, n may not be an integer).
I need to find a
and n
.
Upvotes: 0
Views: 862
Reputation: 2016
Take the logarithm of both sides and use polyfit
or just a plain x = A\b
approach.
y_fit = a*(x_fit).^n
log(y_fit) = log(a) + n*log(x_fit)
If x_fit
and y_fit
are column vectors of data:
A = [ones(length(x_fit), 1), log(x_fit)];
b = log(y_fit);
x = A\b;
n = x(2)
a = exp(x(1))
Upvotes: 2