MATLAB Answers

fit these curves and what type of fit they are?

1 view (last 30 days)
Hi, everybody. Can anyone help me with the fitting of this curves? i think is linear fuction and log/exponetial but I'm not sure.
Here under the code that I'm using... also the documents neeeded for each letter if it's usefull.
Thank you so much in advance!!
A=wdth_2mm;
a_m=mean(A);
a_=std(A);
B=wdth_3mm;
B(B<0)=0;
B(isnan(B))=0;
b_m=mean(B);
b_=std(B);
C=wdth_4mm;
c_m=mean(C);
c_=std(C);
D=wdth_6mm;
d_m=mean(D);
d_=std(D);
E=wdth_8mm;
e_m=mean(E);
e_=std(E);
F=wdth_10mm;
F(F<0)=0;
F(isnan(F))=0;
f_m=mean(F);
f_=std(F);
G=wdth_17mm_new400;
g_m=mean(G);
g_=std(G);
H=wdth_20mm;
h_m=mean(H);
h_=std(H);
mean_wdt=[a_m b_m c_m d_m e_m f_m g_m h_m];
err=[a_ b_ c_ d_ e_ f_ g_ h_];
x_fiber=[2 3 4 6 8 10 17 20];
f_fiber=fit(x_fiber.',mean_wdt.','Exp1');%I try this one but I'm not sure is even exponential
figure(3);
errorbar(x_fiber,mean_wdt,err,'-s','MarkerSize',5,...
'MarkerEdgeColor','red','MarkerFaceColor','red');
xlabel('Fiber lenght(mm)');
ylabel('Width of correlation peak')
title('correlation at different fiber lenghts');
axis([0,22,0,0.015]);
hold on
plot(f_fiber,x_fiber,mean_wdt);

  0 Comments

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 26 Nov 2020
Your data is noisy. There is NO specific function that describes the data. It is NOT truly linear. It is NOT truly exponential, because once the data becomes corrupted with noise, it has lots of other sources of stuff happening.
Those functional forms MAY approximate the data, In fact, they may be reasonable. Or not. It is easy enough to pose infinitely many other model forms that will fit all of those sets of data equally well.
So just pick a model and be happy. Just don't claim the model is correct. It is not.

  3 Comments

Coryn Melissa LLamoza Carabali
oh, thank you! That was my problem.. I get this data and was asked to 'fit it' and say something about it. Didn't really know which it was suppose to be.
John D'Errico
John D'Errico on 26 Nov 2020
Honestly, I'd probably first try a low order polynomial from what I have seen of your data. So let me try a couple of fits, just to see what seems reasonable. The most obvious would be a variation of exponential, by adding a constant term. You need the constant offset here, as exp1 would fail miserably.
ft = fittype('a + b*exp(-c*x)','indep','x');
mdlexp = fit(x_fiber',mean_wdt',ft,'weight',1./err,'start',[.001,.001,.1])
mdlexp =
General model:
mdlexp(x) = a + b*exp(-c*x)
Coefficients (with 95% confidence bounds):
a = 0.001068 (0.0006595, 0.001476)
b = 0.01474 (0.009451, 0.02004)
c = 0.2908 (0.1831, 0.3984)
If you don't provide an intelligent set of starting values for an exponential model, expect crapola for a result.
errorbar(x_fiber,mean_wdt,err,'-s','MarkerSize',5,...
'MarkerEdgeColor','red','MarkerFaceColor','red');
xlabel('Fiber lenght(mm)');
ylabel('Width of correlation peak')
title('correlation at different fiber lenghts');
hold on
plot(mdl)
It could be worse.
format long g
mdlexp.a
ans =
0.00106771635344133
mdlexp.b
ans =
0.0147442104805044
mdlexp.c
ans =
0.290764903016074
Is that the correct model? Who knows?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by