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
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
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);
댓글 수: 0
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!