[Scilab-users] Problem with function fitting
Maihem
unicorn21 at wp.pl
Wed Dec 17 18:53:12 CET 2014
Hi,
I have problem with fitting function to measured data using scilab. I tried
scilab function datafit(), lsqrsolve(), leastsq() but none returns me a
proper result or can't perform calculations.
//I have measured data:
xm;ym
2.0;99.9449173761
1.0;99.8097145719
0.5;97.9769654482
0.25;36.4046069104
0.1;1.4872308463
0.071;0.5207811718
0.063;0.3705558338
//Script used to fit data
miny=min(ym);
maxy=max(ym);
minx=min(xm);
maxx=max(xm);
Zz=[xm;ym];
//Function describing problem (I want to find best fit by finding n()).
function g1=f1(x, n)
g1 = miny+((maxy-miny) ./((1+(n(1).*(x ./n(2)).^n(3))+(1-n(1)).*((x
./n(2)).^n(4)))).^n(5))
endfunction
function e = G(n,z)
xm = z(1)
ym = z(2)
e = ym - f1(xm,n)
endfunction
n0 = [1 ; 1; 1; 1; 1]
[n0_opt,err] = datafit(G,Zz,n0)
After calling function scilab returns me error:
Variable returned by scilab argument function is incorrect.
I tried to find solution for this problem in scilab mailing lists and tried
some posted scripts and advices but I can't localize problem.
Łukasz
--
View this message in context: http://mailinglists.scilab.org/Problem-with-function-fitting-tp4031546.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
More information about the users
mailing list