* ( yth ( tm, x ) - ym ) endfunction lb = ub = // the simplest call = lsqnonlin ( myfun, x0, lb, ub ) // Press ENTER to continue A simple nonlinear least square example taken from leastsq default present in scilab function y = yth ( t, x ) y = x ( 1 ) * exp ( - x ( 2 ) * t ) endfunction // we have the m measures (ti, yi): m = 10 tm = ' ym = ' // measure weights (here all equal to 1.) wm = ones ( m, 1 ) // and we want to find the parameters x such that the model fits the given // data in the least square sense: // // minimize f(x) = sum_i wm(i)^2 ( yth(tm(i),x) - ym(i) )^2 // initial parameters guess x0 = // in the first examples, we define the function fun and dfun // in scilab language function y = myfun ( x, tm, ym, wm ) y = wm. You will find a series of problems and the appropriate code snippets to solve them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |