Optimization function with a summation
이전 댓글 표시
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
Matt J
2021년 1월 10일
With what constraints on b(i)? Without any constraints, the minimum of f_sum is -infinity.
Ricardo López
2021년 1월 10일
Ricardo López
2021년 1월 10일
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
2021년 1월 10일
The solution is simply,
b = zeros(144,5);
b(PV(1:j)>0,:)=1;
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!