Objective function in a for loop

1 回表示 (過去 30 日間)
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2018 年 10 月 24 日
回答済み: Torsten 2018 年 10 月 25 日
hi all,
I have an objective function that I want to minimize
N=10
f=@(x) ((0.0011*(x(2:1*N)-x(1:N-1)))'*exp(-0.0078*x(4*N+1:4*N+N-1)))*3/20
is it possible to create a for loop so that the function changes for each i, like this?:
for i=2:10
f=@(x) ((0.0011*(x(i):1*N)-x((i-1):N-1)))'*exp(-0.0078*x(4*N+1:4*N+N-1)))*3/20
end
thanks
Nikolas

回答 (1 件)

Torsten
Torsten 2018 年 10 月 25 日
No, because the number of elements of ((0.0011*(x(i):1*N)-x((i-1):N-1))) must always be N-1.

カテゴリ

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