Effacer les filtres
Effacer les filtres

How to form objective function with a class instance and a set of variables

2 vues (au cours des 30 derniers jours)
JFz
JFz le 23 Août 2017
Commenté : JFz le 24 Août 2017
Hi,
I am trying to minimize an objective function by using fmincon(fun,x0,A,b,Aeq,beq,lb,ub). But I am having some difficulties forming the objective function fun. The fun I defined has two inputs, one is an instance of a class I defined (Myclass), another input is the array of independent variable X. In the function, I plug in X into the Myclass instance's method. But I got this error: Struct contents reference from a non-struct array object.
I know that fun can take only one input; but in the fun, I need the other input parm to calculate. How to solve this problem?
Thank you very much for any help.
Jennifer

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Août 2017
  2 commentaires
JFz
JFz le 23 Août 2017
Thank you so much! Let me read and test....
JFz
JFz le 24 Août 2017
It works! Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by