How to fit a curve with negative powers of x

31 次查看(过去 30 天)
Hi!
I am currently trying to find an asymptote of a graph on MATLAB in order for this to be possible the formula must have negative powers of x. At the moment I am using the "polyfit" function but this does not seem to have the capability of returning a curve with any negative powers of x. If anyone can help me to plot a best fit curve with negative powers of x or knows of another way to find an asymptote it would be greatly appreciated! (I have included an image of one of the graphs I'm trying to fit in case that helps!)
  1 个评论
Guillaume
Guillaume 2018-9-6
Well, yes polyfit is to fit to polynomials which an expression with negative powers certainly isn't.
I believe that for arbitrary function fitting you need the curve fitting toolbox. You may also have a look on the FileExchange to see if there's something that fits the bill.

请先登录,再进行评论。

回答(2 个)

Fredrik P
Fredrik P 2022-11-10
移动:Image Analyst 2022-11-10
For the benefit of posterity:
x = 1:20;
y = 5 - x.^(-1);
p = polyfit(1 ./ x, y, 1);
yhat = polyval(p, 1 ./ (1:30));
figure;
hold on;
plot(y, 'o');
plot(yhat);

Torsten
Torsten 2018-9-6
If you want to fit parameters a0,...,an to a function of the form
y = a0 + a1*x^(-1) + a2*x^(-2) + ... + an*x^(-n)
you can simply use polyfit for the data points (1/xi,yi).
Best wishes
Torsten.

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by