# How to plot a best fit curve to my data points?

37 views (last 30 days)

Show older comments

Hi,

I have attached a data (inverted_qp.mat Inv_qpAVO freq;) and a plot between fre and Inv_qpAVO is shown below in red color.

circled points on left hand side are the issue and I want to a best-fit curves passes through these points just like shown on the right hand side figure (in blue color a solid line).

The best fit curve should start from the fist point to the end point as given a solid blue line. Thanks

##### 7 Comments

Sam Chak
on 3 Jun 2022

### Answers (2)

Kevin Holly
on 2 Jun 2022

##### 1 Comment

John D'Errico
on 3 Jun 2022

<Moved to a comment from @Nisar Ahmed

Nisar Ahmed
on 3 Jun 2022

##### 1 Comment

Torsten
on 3 Jun 2022

Edited: Torsten
on 3 Jun 2022

p(1) = -0.137921750658333;

p(2) = 4.83156544429652E-5;

p(3) = -3.87422699831525E-7;

p(4) = 0.000904269701487609;

p(5) = 0.138139976684668;

p(6) = -0.000327312583052385;

f = @(x)p(1) + p(2)*x + p(3)*x.^1.5 + p(4).*log(x) + p(5).*exp(p(6).*x);

plot(x,f(x))

### See Also

### Community Treasure Hunt

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

Start Hunting!