フィルターのクリア

Optimization function with a summation

4 ビュー (過去 30 日間)
Ricardo López
Ricardo López 2021 年 1 月 10 日
コメント済み: Matt J 2021 年 1 月 10 日
Good afternoon,
I have the following code:
C_H = [C_H1 C_H2 C_H3 C_H4 C_H5];
PV = reshape(PV_SAM,[52560,1]);
j = 144;
fun =zeros(144,5);
b = zeros(144,5);
for i=1:j
fun(i,:) = (C_H(i,:) - b(i).*PV(i));
end
f_sum = sum(fun,'all');
Does anyone know how to optimize the variable b so the value of f_sum is minimum?
Thank you
  4 件のコメント
Ricardo López
Ricardo López 2021 年 1 月 10 日
And the sum of all of them should be 1
Matt J
Matt J 2021 年 1 月 10 日
C_H does not affect the optimization at all and PV only has one column, so giving b 5 columns is only creating extra redundant variables.

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

回答 (1 件)

Matt J
Matt J 2021 年 1 月 10 日
The solution is simply,
b = zeros(144,5);
b(PV(1:j)>0,:)=1;
  2 件のコメント
Ricardo López
Ricardo López 2021 年 1 月 10 日
The sum of all of them should be one and the solution that this is giving is just 1 for all 5 columns.
Matt J
Matt J 2021 年 1 月 10 日
編集済み: Matt J 2021 年 1 月 10 日
[~,i]=max( PV(1:j));
b = zeros(144,5);
b(i,1)=1;

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

カテゴリ

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