MATLAB: Curve Fitting and Distribution Fitting

curve fittingStatistics and Machine Learning Toolbox

Hello. I have three sets of data and an equation based on it. How can I fit a curve on it and get the coefficients(c1,c2,c3,c4,c5,c6,c7)?and estimate root mean square errors (RMSE) and correlation coefficient (R2)
ye = [0.166393443
0.206557377
0.25204918
0.280737705
0.306967213
0.323770492
0.352868852
0.378278689
0.412704918
0.432786885
0.44057377
0.456147541
0.475819672];
Q = [0.040755669
0.067112106
0.10495312
0.132849355
0.160791371
0.179781479
0.214383688
0.246026104
0.290251909
0.316344405
0.326446015
0.346526208
0.371457751];
z=[0
0
0
0
0
0
0
0
0
0
0
0
0];
1.6<=c7<=3
Q= ((c1-(c2*(ye+z)))*(asin(ye)^c3)+c4*((ye+z)^c5)*ye+(z^c6))^c7;

Best Answer

Try this:
yez = [ye, z];
Qf = @(c1,c2,c3,c4,c5,c6,c7,yez) ((c1-(c2.*(yez(:,1)+yez(:,2)))).*(asin(yez(:,1)).^c3)+c4.*((yez(:,1)+yez(:,2)).^c5).*yez(:,1)+(yez(:,2).^c6)).^c7;
Qfcn = @(cv,yez) Qf(cv(1),cv(2),cv(3),cv(4),cv(5),cv(6),cv(7),yez);
B = lsqcurvefit(Qfcn, [rand(6,1);2], yez, Q, [-Inf(1,6) 1.6], [Inf(1,6) 3])
The estimated parameters do not appear to be unique. This produces quite different results in different runs.