How do I curve fit the data set
7 次查看(过去 30 天)
显示 更早的评论
Hello all,
I'm facing difficulty in fitting the data.
The red ones are from the data set, and I want to fit that as like blue one (Experimental Data). How can I do that. I have also attached the data set for your reference.
Thank You.
2 个评论
Sam Chak
2023-7-29
Can you also suggest some candidate functions for fitting into the red data? Look up some Kernel functions.
Red data seems to have discontinuities at multiple intervals. Is it acceptable to have a piecewise function to fit the data?
采纳的回答
Sam Chak
2023-7-29
Not sure if this is what your want. But you can try finding the best math function to fit.
data = load('curve_fit.mat');
x = data.theta_degree';
y = data.x';
skewEqn = 'a/(sqrt(2*pi))*exp(- b*(x - c)^2)*((1/2)*(1 + erf(e*(x - c)/sqrt(2)))) + d';
fo = fitoptions('Method', 'NonlinearLeastSquares',...
'Lower', [ 0, 0, 5, 0, 0.1],... % {a, b, c, d, e}
'Upper', [100, 1, 20, 10, 1.0],...
'StartPoint', [50 0.5 10 5 0.5]);
ft = fittype(skewEqn, 'options', fo);
[yfit, gof] = fit(x, y, ft)
plot(yfit, x, y)
grid on, xlabel('\theta'), ylabel('x')
legend('Data', 'Fitted Skew Dist Fcn')
2 个评论
更多回答(1 个)
Alex Sha
2023-7-29
@Prajwal Magadi, one more function:
Sum Squared Error (SSE): 75571.6557870726
Root of Mean Square Error (RMSE): 2.74902993412354
Correlation Coef. (R): 0.962878352853849
R-Square: 0.927134722394541
Parameter Best Estimate
--------- -------------
y0 3.57509887406416
a 10210313.7484567
xc 17.1109591760412
w1 18.7010167618592
w2 -1.38399464317597
w3 -1.49504622174935
3 个评论
Alex Sha
2023-7-29
Hi, your data chart looks like peak-type function chart, so just try some typical peak functions, "Asym2Sig" function, shown above, gives more better outcomes.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!