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

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

And do you have a preference about the function for the fit curve you want to take to approximate the red data points ?
@Torsten approximate of the red data points will be fine.
Try the model below:
y = p1+p2*x+p3*x^1.5+p4*log(x)+p5*exp(p6*x)
Sum Squared Error (SSE): 1.59130623291519E-6
Root of Mean Square Error (RMSE): 0.00031536746749974
Correlation Coef. (R): 0.970802539336279
R-Square: 0.942457570381768
Adjusted R-Square: 0.93360488890204
Determination Coef. (DC): 0.942457570381768
Chi-Square: 0.000179198129320299
F-Statistic: 32.7569613131459
Parameter Best Estimate Std. Deviation Confidence Interval[95%]
--------- ------------- -------------- -------------------
p1 -0.137921750658333 0.174070650978335 [-0.525775331093703, 0.249931829777037]
p2 4.83156544429652E-5 6.41506994605273E-5 [-9.46210114071306E-5, 0.000191252320293061]
p3 -3.87422699831525E-7 5.2372155346116E-7 [-1.55434704072094E-6, 7.79501641057892E-7]
p4 0.000904269701487609 0.000207649174901467 [0.000441598507306757, 0.00136694089566846]
p5 0.138139976684668 0.174107523689351 [-0.249795761270695, 0.526075714640031]
p6 -0.000327312583052385 7.19593900360924E-5 [-0.000487648095757037, -0.000166977070347734]
Bravo, Alex.
One question though. Does anyone with a decent knowledge of math functions be able to intellectually figure out the proposed model?
It's a combination of fractional polynomial, logarithmic function and exponential function.
f(x) = p1 + p2*x + p3*x^1.5 + p4*log(x) + p5*exp(p6*x)
In my opinion you should pick a model that is meaningful and based on some theory. I doubt the physics of the situation has a theoretical model that complicated, but it might. I also doubt the point at 0,0 was a measured point. I think it was just assigned thinking that's what it should be. If it weren't for that point I'd have thought an exponential decay function might be good. If it's a real point, then perhaps some kind of log-normal equation would be good and log-normal is the theoretical equation in a lot of situations. Or maybe a Rayleigh curve. But if it is a log-normal curve then you should get more points between 0 and the peak. How can we get a good fit with so much data missing from a crucial region? Plus there are way too few points out on the right side. Look at the noise around the peak. It's like 20%. But look out on the right side. You just have 3 or 4 points and the curve pretty much goes through them and the curve coefficients are greatly determined by those. If you didn't have those but had some more measured points that were around 20% different than those, the coefficients of the curve would be vastly different. So that's why I don't trust the curve coefficients without getting extra observations on the left side and right side of the plot.
@Nisar Ahmed Please stop using a new answer every time you want to make a comment.
@Image Analyst, thanks for the insights into the analysis of the data that provides a basis for understanding the curve fitting. 👍

Sign in to comment.

Answers (2)

If you have the Curve Fitting Toolbox, you can use the Curve Fitting app after you import your data into the workspace. Within the app, there are many curve fits you could select from. Here is a video showing the process.
@Alex Sha thank you for you answer,
I am sorry I did not understand, do you mean, I need to compute
f(x) = p1 + p2.*x + p3*x.^1.5 + p4.*log(x) + p5.*exp(p6.*x)
while using
p1 = -0.137921750658333;
p2 = 4.83156544429652E-5;
p3 = -3.87422699831525E-7;
p4 = 0.000904269701487609;
p5 = 0.138139976684668;
p6 = -0.000327312583052385;
and x = Inv_qpAVO;
I am trying as I wrote above and having this error
Array indices must be positive integers or logical values.
Error in InQP_f (line 29)
f(x) = p1 + p2.*x + p3*x.^1.5 + p4.*log(x) + p5.*exp(p6.*x)

1 Comment

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))

Sign in to comment.

Categories

Asked:

on 2 Jun 2022

Commented:

on 3 Jun 2022

Community Treasure Hunt

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

Start Hunting!