Use function handle in which past values are used

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 commentaires

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
KB le 27 Nov 2019
I am using the free Matlab version for students and haven't access to the Optimization Toolbox.
But I solved this with an external function, which is called by the function handle.
Thank you four your help :)

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Optimization Toolbox dans Centre d'aide et File Exchange

Question posée :

KB
le 26 Nov 2019

Commenté :

KB
le 27 Nov 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by