如何编写自变量个数未定的目标函数。

我有一个优化问题
目标函数是 (C+x1) * (C + x2) * (C+ x3) * ... 自变量x的个数由前面的程序给出
约束函数是标准的线性函数
A * [ x1; x2; x3; ...] <= CC
我的问题是:
比如自变量的个数是N,那么如何写目标函数呢?
用M文件不方便吧?
用函数句柄该怎么写?
以及:
该优化问题可以用fmincon来求解吧

 Réponse acceptée

vebijw
vebijw le 24 Nov 2022

0 votes

f = (C+x(1)) * (C+x(2)) * (C+x(3)) * .... 可以表示成向量形式的计算。
也就是 f = prod(C+x),prod表示向量的各个元素连乘

Plus de réponses (0)

Catégories

En savoir plus sur 图形对象 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!