How can I maximize a function in Matlab?

27 ビュー (過去 30 日間)
Abdullah Türk
Abdullah Türk 2019 年 9 月 9 日
コメント済み: John D'Errico 2019 年 9 月 9 日
Hi everyone,
A(i,1) = sum(B(i,:)) + C*3;
I have function A as above. I wan t to maksimize this function. How can I do this?
Thanks.
  4 件のコメント
John D'Errico
John D'Errico 2019 年 9 月 9 日
編集済み: John D'Errico 2019 年 9 月 9 日
Why did you unaccept Jan's answer? It is the correct solution. What was wrong with it? Just negate the function, exactly as he said. Then you are minimizing the negative of your function, which maximizes it! So WTP?
Abdullah Türk
Abdullah Türk 2019 年 9 月 9 日
I didn't say Jan's answer was wrong. I applied the Jan's answer for my code and obtained the right result. So, there are no problems left.

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

採用された回答

Jan
Jan 2019 年 9 月 9 日
Matlab contains some tools for minimization. A maximization does exactlly the same, if you change the sign of the optimization criterion.
  4 件のコメント
Abdullah Türk
Abdullah Türk 2019 年 9 月 9 日
Jan and John D'Errico thank you both. I applied the solution you suggested above and after a bit of work I maximized the my problem. Thanks again.
John D'Errico
John D'Errico 2019 年 9 月 9 日
In fact, most optimizers seem to be minimization codes. It just seems a logical standard, since often one wants to minimize a sum of squares, perhaps. That may acttually be the most common general class of optimization problem overall anyway. So it makes sense that all optimizers will be consistent, thus minimizers. That way you need not remember which direction some tool works, as opposed to others. And of course, negating a function makes a min into a max, and vice versa.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by