i have bunch of data have fit following formula: [x*sin(1/x)]^2
. don't know coefficients pick such function, tried:
model = fittype('a*((xx/b)*sin(b/xx))^2+c','independent',{'xx'},'dependent',{'ff_norm(:,i)'}, 'coefficients', {'a','b','c'}); opt=fitoptions(model); myfit=fit(xx,ff_norm(:,i),model, opt); myfit plot(myfit,xx,ff_norm(:,i))
i fit looks straight line. know it's better enter start points well, have no idea how pick these because don't know how matlab interprets them , mean. when try numbers, it's giving me errors.
i not sure problem encounter, tried reproduce problem code:
xx = (0.1:0.1:10).'; error = rand(size(xx)).*2; data = 5.*((xx./6).*sin(6./xx)).^2+7+error; model = fittype('a.*((xx./b)*sin(b./xx)).^2+c','independent',{'xx'},'dependent'... ,{'data'}, 'coefficients', {'a','b','c'}); opt = fitoptions(model); opt.startpoint = [1 1 1]; [myfit,gof] = fit(xx,data,model,opt) plot(myfit,xx,data);
and gave me output:
myfit = general model: myfit(xx) = a.*((xx./b)*sin(b./xx)).^2+c coefficients (with 95% confidence bounds): = 5.18 (4.846, 5.514) b = 6.318 (5.84, 6.796) c = 7.995 (7.777, 8.213)
which quite correct, , plot looks fine:
indeed, not works on first try, should try several times, until fine. way using while
loop , gof
(goodness of fit) output fit
function, search adequate parameters model. result above:
gof = sse: 27.757 rsquare: 0.91357 dfe: 97 adjrsquare: 0.91178 rmse: 0.53493
this off course depend on how data have, fact true.
Comments
Post a Comment