Use function handle in which past values are used
Show older comments
Hello,
I have the input and output data of a real system:
xdata = U_set; % setted voltage
ydata = U_meas; % measured voltage
My goal is to use the function lsqnonlin to apply the Levenberg-Marquardt method and get the estimated parameter vector for the following assumed input-output-relationship:
x()... parameters
x... input from xdata
y... model output
There is an example in which the function fun doesn't contain past values of the model
or past values of the input
https://de.mathworks.com/help/optim/ug/lsqnonlin.html
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];
fun = @(x)x(1)*exp(x(2)*xdata)-ydata;
x0 = [100,-1];
options = optimoptions(@lsqnonlin,'Algorithm','trust-region-reflective');
x = lsqnonlin(fun,x0,[],[],options)
How can I implement a function, in which past values of xdata or ydata can be used to use my assumed model in fun?
Best regards
KB
2 Comments
Vladimir Sovkov
on 26 Nov 2019
You can program it as a separate function using loops, and convert it to optimization expression with the help of the call function fcn2optimexpr from Matlab Optimization Toolbox.
You can also try our package Optimizer at https://sourceforge.net/projects/optimizer-sovkov/
KB
on 27 Nov 2019
Answers (0)
Categories
Find more on Optimization Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!