Effacer les filtres
Effacer les filtres

Problem passing function to lsqnonlin with costant parameters

1 vue (au cours des 30 derniers jours)
Eugenio Grabovic
Eugenio Grabovic le 15 Jan 2019
Commenté : Eze Far le 5 Juil 2023
Hello, i have this function to pass to lsqnonlin :
[val,Jac] = myfunction(x,par1,par2,par3)
my function computes already the Jacobian that im planning to pass to slqnonlin and is essential.
x is the optimization variable and par1,par2... are constant parameters required to evaluate the function and are computed separately.
The problem then is how i declare x as the only optimization variable?
I can't use function handle otherwise i would lose my multi ouput;
I can't declare par1,par2,... as globals cause myfunction has parallelization in it;
I could pass the code to evaluate pars into myfunction but it would add not necessary heavy computation into each iteration of lsqnonlin which i'd like to avoid;
Any other ideas? Thank you

Réponse acceptée

Matt J
Matt J le 15 Jan 2019
Modifié(e) : Matt J le 15 Jan 2019
par1=______;
par2=______;
par3=______;
lsqnonlin(@(x) myfunction(x,par1,par2,par3), __________);
  6 commentaires
Matt J
Matt J le 4 Juil 2023
@Eze Far Yes, it will.
Eze Far
Eze Far le 5 Juil 2023
@Matt J thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Problem-Based Optimization Setup dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by