Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: lsqcurvefit using multistart
Replies: 2   Last Post: Jul 31, 2013 10:59 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
James

Posts: 2
Registered: 7/30/13
lsqcurvefit using multistart
Posted: Jul 30, 2013 2:32 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I'm not sure if this is a misunderstanding on my end, but I had a frustrating morning getting lsqcurvefit working with the multistart function.

I'm doing an inverse FE analysis to fit some material constants to experimental data. To do the fit, I'm using lsqcurvefit and calling my external finite element code in the fit function.

Everything seems to be working correctly, I can accurately fit the simulated data to the experimental data. However, I want to use the multistart function to reduce the dependence on the initial guess.

I have created the code below to run the analysis with the lsqcurvefit algorithm:

[param,resnorm] = lsqcurvefit(@fit_function,initial_guess,xdata,ydata,lb,ub,options);

%%% fit function
function ydata = fit_function(x,xdata)

write_input_file(x);
system('./mainexe 1>NULL');
ydata = get_input_file();
%%% fit function

I change the code to use the multistart function:
problem = createOptimProblem('lsqcurvefit','x0',initial_guess,'objective',@fit_function...
,'xdata',xdata','ydata',ydata,'options',options);
ms=MultiStart;
[param,resnorm] = run(ms,problem,5);

Running the code, I get the following error after the first step:
??? Error using ==> lsqcurvefit at 253
Function value and YDATA sizes are incommensurate.

A little detective work shows that the while xdata is a 1xn vector, ydata is a nx1 vector. I need to add the following line to the end of my fit function to get the code to work correctly:
ydata=ydata';

Why does the code work without this change when using the lsqcurvefit function but not when using the multistart algorithm?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.