0

我正在尝试找到如下所述的拟合曲线。MATLABpolyfit在我的情况下不起作用。
已知参数:xy,以及拟合曲线y_fit = a * (x_fit) .^ n
(这里,n 可能不是整数)。
我需要找到an

4

1 回答 1

2

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))
于 2012-05-28T15:55:51.813 回答