From: Sara on 25 Feb 2010 14:30 I'm trying to use this but when I debug I see that it assumes the constants as my Ydata, I tried different things but it seems not working. Any suggestions? Thank you in advance, Sara "Mihir Mudholkar" <mihir.mudholkar(a)gmail.com> wrote in message <gq8djt$e14$1(a)fred.mathworks.com>... > Thank you John, your method worked! > > Mihir > > "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <gq873q$64f$1(a)fred.mathworks.com>... > > "Mihir Mudholkar" <mihir.mudholkar(a)gmail.com> wrote in message <gq869h$7i$1(a)fred.mathworks.com>... > > > Hi, I am trying to create an objective function to be used in optimization for lsqcurvefit(). I have been able to use lsqcurvefit without any problem as long as the input arguments in the objective function are only param and xdata. i.e. the objective function is defined as > > > function output = myfun(param, xdata) > > > Using the above objective function, I am able to use lsqcurvefit. > > > However, my problem is that I am performing redundant calculations inside myfun for every loop of optimization (calculation of constants based on xdata for e.g.) and I am wondering if there is any way to pass those constants as input arguments for myfun. Something like > > > function output = myfun(param,xdata,constants) > > > This will reduce the computation time for lsqcurvefit by a lot. > > > If anyone knows how to pass constants in objective functions, please help me. > > > > > > Thank You, > > > Mihir > > > > Use an anonymous function, calling lsqcurvefit > > as follows: > > > > lsqcurvefit(@(param,xdata) myfun(param,xdata,constants), ... > > > > HTH, > > John
|
Pages: 1 Prev: netcdf.putVar fails to write entire matrix Next: Battery simulation |