How to fit a curve with negative powers of x

28 ビュー (過去 30 日間)
Iain Christie
Iain Christie 2018 年 9 月 6 日
移動済み: Image Analyst 2022 年 11 月 10 日
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 Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by