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

1 回表示 (過去 30 日間)
JFz
JFz 2017 年 8 月 23 日
コメント済み: JFz 2017 年 8 月 24 日
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

採用された回答

Walter Roberson
Walter Roberson 2017 年 8 月 23 日
  2 件のコメント
JFz
JFz 2017 年 8 月 23 日
Thank you so much! Let me read and test....
JFz
JFz 2017 年 8 月 24 日
It works! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by