フィルターのクリア

How can i sum my objective function with each iteration

2 ビュー (過去 30 日間)
Azime Beyza Ari
Azime Beyza Ari 2022 年 3 月 22 日
コメント済み: Matt J 2022 年 3 月 22 日
Hello everyone,
I am trying to do an maximiztion with optimization toolbox using genetic algorithm solver. What i am trying to do is i have a function with 2 parameters and 1 variable. I have a for loop and in the loop i wanna do this.
for i = 1:1
for j = 1:1296
z = z + (-1)*(xij(36*i+j-36)*aii(i,j)*r(i,j));
end
end
I wanna multpily the x,r, and a for each iteration and sum every iteration.
like this;
for (1,1)
x(1,1)*r(1,1)*a(1,1) = 188
for (1,2)
x(1,2)*r(1,2)*a(1,2)=74 +188= 262 (you get the idea)
Any suggestions on how to do this?
Because when i write it this was i get an error.
z = z + (-1)*(xij(36*i+j-36)*aii(i,j)*r(i,j));
Thank you in advance,
Beyza.

採用された回答

Matt J
Matt J 2022 年 3 月 22 日
sum(x.*r.*a,'all')
  16 件のコメント
Azime Beyza Ari
Azime Beyza Ari 2022 年 3 月 22 日
@Matt J okey thank you!
Matt J
Matt J 2022 年 3 月 22 日
You're welcome. If the problem is now resolved, though, please do Accept-click the answer.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by