How to fit a curve with negative powers of x
31 views (last 30 days)
Show older comments
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 Comment
Guillaume
on 6 Sep 2018
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.
Answers (2)
Fredrik P
on 10 Nov 2022
Moved: Image Analyst
on 10 Nov 2022
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 Comments
Torsten
on 6 Sep 2018
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 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!