The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: lsqcurvefit using multistart
Replies: 3   Last Post: Jun 5, 2014 12:09 PM

Advanced Search

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

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)

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...
[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:

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]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.