How to fit a curve with negative powers of x

조회 수: 31 (최근 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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by