Custom fit curve and plotted curve are different, help

62 次查看(过去 30 天)
Hi everyone, I'm using the Fitter App to fit some point with a custom equation, the fit is done correctly but when I put the same values for the same parameters in a MATLAB to plot the points with a scatterplot and the fit curve like a plot the fit curve is shifted up or down, and I have to manually adjust the parameters to get a decent looking graph (I'm posting an example)
  4 个评论
Sam Chak
Sam Chak 2024-6-14
Hi, please show the 6 data points and the selected fitting model. Looks like the slope is very high.
A 5th degree polynomial should perfectly go through all 6 points.
Armando
Armando 2024-6-14
I fitted them linearly (they depend on a cosine and I previously calculated the cos(x)). Non-linearized data (visible in my original post) is fitted on (dr/(2*pi) + 2*d*cos(x))/L and L is fixed at 6.3280e-07.
FYI my six points are
6.0000 0.0047
5.0000 0.0103
4.0000 0.0141
3.0000 0.0174
2.0000 0.0193
1.0000 0.0212
x is the second column

请先登录,再进行评论。

回答(1 个)

Shlok
Shlok 2024-7-16,4:49
Hi Armando,
I understand that you are trying to manually fit the curve on a scatterplot using the parameters generated by the Curve Fitter app. But you are unable to replicate the plot because the fit curve is not in the same position as the one displayed in the Curve Fitter app.
For reference, I have used the equation and coordinates provided to calculate the fit curve and obtained the following parameters.
This is happening because the values displayed in the result tab are being copied and used directly as an input to the manual curve plotting code. It is important to note that these values are rounded to 4 decimal places in GUI and, hence, are not accurate enough to replicate the Curve Fitter plot. Even the slightest change in these values can shift the curve by a lot.
To manually plot the graph, we need the parameter values exactly same as the calculated values. You can refer the following steps to achieve the same:
  • Export the variables to the workspace from the Curve Fitter app. While exporting, multiple variables will be visible. We just need to save the fit (“fittedmodel”, for example).
  • Now, we can manually use the parameter values calculated in the Curve Fitter app (“fittedmodel.d” and “fittedmodel.dr”, for example) in the script.
  • For further investigation, we can also view the parameter values in higher decimal places, using “format long. For example:
Check out the following documentation link to know more about the Curve Fitter app:
Hope this helps.
Regards,
Shlok

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by