0
votes

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.

1

1 Answers

2
votes

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))