From: Eli Melaas on 9 Jun 2010 17:05 I am trying to use the lsqcurvefit function as such: M.file - "Phenocam" xdata = [0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; ydata = [455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5]; x0 = [100; -1]; % Starting guess [x,resnorm] = lsqcurvefit(@my_fun_Phenocam,x0,xdata,ydata); M.file - "my_fun_Phenocam" function F = my_fun_Phenocam(x,xdata) F = x(1)*exp(x(2)*xdata); .......and I am consistently getting the following error message: ??? Error using ==> feval Undefined function or method 'my_fun_Phenocam' for input arguments of type 'double'. Error in ==> lsqcurvefit at 209 initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:}); Caused by: Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot continue. Any ideas what is wrong with my code? Thanks!
From: Walter Roberson on 9 Jun 2010 17:07 Eli Melaas wrote: > I am trying to use the lsqcurvefit function as such: > > M.file - "Phenocam" > xdata = [0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; > ydata = [455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5]; > x0 = [100; -1]; % Starting guess > [x,resnorm] = lsqcurvefit(@my_fun_Phenocam,x0,xdata,ydata); > > M.file - "my_fun_Phenocam" > function F = my_fun_Phenocam(x,xdata) > F = x(1)*exp(x(2)*xdata); > > ......and I am consistently getting the following error message: > ??? Error using ==> feval > Undefined function or method 'my_fun_Phenocam' for input arguments of > type 'double'. > Error in ==> lsqcurvefit at 209 > initVals.F = > feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:}); > Caused by: > Failure in initial user-supplied objective function evaluation. > LSQCURVEFIT cannot continue. > > Any ideas what is wrong with my code? Is it possible that your second M file is named my_fun_Phenocam with no extension? Or is it named my_fun_Phenocam.m ?? It needs the .m extension to be found.
From: Eli Melaas on 9 Jun 2010 17:12 Walter Roberson <roberson(a)hushmail.com> wrote in message <huovt9$jr9$1(a)canopus.cc.umanitoba.ca>... > Eli Melaas wrote: > > I am trying to use the lsqcurvefit function as such: > > > > M.file - "Phenocam" > > xdata = [0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; > > ydata = [455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5]; > > x0 = [100; -1]; % Starting guess > > [x,resnorm] = lsqcurvefit(@my_fun_Phenocam,x0,xdata,ydata); > > > > M.file - "my_fun_Phenocam" > > function F = my_fun_Phenocam(x,xdata) > > F = x(1)*exp(x(2)*xdata); > > > > ......and I am consistently getting the following error message: > > ??? Error using ==> feval > > Undefined function or method 'my_fun_Phenocam' for input arguments of > > type 'double'. > > Error in ==> lsqcurvefit at 209 > > initVals.F = > > feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:}); > > Caused by: > > Failure in initial user-supplied objective function evaluation. > > LSQCURVEFIT cannot continue. > > > > Any ideas what is wrong with my code? > > > Is it possible that your second M file is named > > my_fun_Phenocam > > with no extension? Or is it named > > my_fun_Phenocam.m > > ?? It needs the .m extension to be found. Both files do have the ".m" file extension.
From: Walter Roberson on 9 Jun 2010 18:00 Eli Melaas wrote: > Walter Roberson <roberson(a)hushmail.com> wrote in message > <huovt9$jr9$1(a)canopus.cc.umanitoba.ca>... >> Eli Melaas wrote: >> > I am trying to use the lsqcurvefit function as such: >> > > M.file - "Phenocam" >> > xdata = [0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; >> > ydata = [455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5]; >> > x0 = [100; -1]; % Starting guess >> > [x,resnorm] = lsqcurvefit(@my_fun_Phenocam,x0,xdata,ydata); >> > > M.file - "my_fun_Phenocam" >> > function F = my_fun_Phenocam(x,xdata) >> > F = x(1)*exp(x(2)*xdata); >> > > ......and I am consistently getting the following error message: >> > ??? Error using ==> feval >> > Undefined function or method 'my_fun_Phenocam' for input arguments >> of > type 'double'. >> > Error in ==> lsqcurvefit at 209 >> > initVals.F = > >> feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:}); >> > Caused by: >> > Failure in initial user-supplied objective function evaluation. > >> LSQCURVEFIT cannot continue. >> > > Any ideas what is wrong with my code? > Both files do have the ".m" file extension. Do the files happen to be stored in one of Matlab's installation directories? If so then "Don't do that", and if you must do that then you would need to use rehash . Do the files happen to be stored in different directories? If so then are both directories on the path? How are you starting the first file? Positioning to it and pressing F5? If so then it would write the text to a temporary file and execute that, which is different than if you were to go to the command line and command Phenocam from there -- in the second case it would have to find the function on the search path. Have you quit Matlab and restarted since the problem began, in order to determine whether it might be a problem with Matlab holding on to old versions of files?
From: Wayne King on 9 Jun 2010 18:34 "Eli Melaas" <eli.melaas(a)gmail.com> wrote in message <huovm7$5v2$1(a)fred.mathworks.com>... > I am trying to use the lsqcurvefit function as such: > > M.file - "Phenocam" > xdata = [0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; > ydata = [455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5]; > x0 = [100; -1]; % Starting guess > [x,resnorm] = lsqcurvefit(@my_fun_Phenocam,x0,xdata,ydata); > > M.file - "my_fun_Phenocam" > function F = my_fun_Phenocam(x,xdata) > F = x(1)*exp(x(2)*xdata); > > ......and I am consistently getting the following error message: > ??? Error using ==> feval > Undefined function or method 'my_fun_Phenocam' for input arguments of type 'double'. > Error in ==> lsqcurvefit at 209 > initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:}); > Caused by: > Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot continue. > > Any ideas what is wrong with my code? > > Thanks! Hi Eli, I don't have any problem with this example. Are you trying to run the code: xdata = [0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; ydata = [455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5]; x0 = [100; -1]; % Starting guess [x,resnorm] = lsqcurvefit(@my_fun_Phenocam,x0,xdata,ydata); inside of the function defined by: function F = my_fun_Phenocam(x,xdata) F = x(1)*exp(x(2)*xdata); ?? You should save this: function F = my_fun_Phenocam(x,xdata) F = x(1)*exp(x(2)*xdata); and ONLY that code in a file called my_fun_Phenocam.m and make sure you save it in a directory that is Matlab's path. Let's save you have a directory c:\mfiles, or /user/mfiles. Save my_fun_Phenocam.m with just the above two lines of code in that directory and then add that to the Matlab path >>addpath 'c:\mfiles' % or addpath '/user/mfiles' Then run: xdata = [0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; ydata = [455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5]; x0 = [100; -1]; % Starting guess [x,resnorm] = lsqcurvefit(@my_fun_Phenocam,x0,xdata,ydata); at the Matlab command prompt. Hope that helps, Wayne
|
Next
|
Last
Pages: 1 2 Prev: error using lsqcurvefit function Next: error using lsqcurvefit function |