Find minimum of variable by altereing two variables.

조회 수: 1 (최근 30일)
Nils Norlander
Nils Norlander 2017년 2월 28일
편집: dpb 2017년 2월 28일
Hello!
I'm simulating an energy system and trying to minimize a variable by altering battery size and level of power consumption in an if loop. At the time I'm just altering the battery and level of power manually, but is there a way to alter them automatically to find a minimum?
See code if anything is unclear. It is "E_bat_max" and "Allowed_summer" I'm altering to minimize "overload".
for j = 2061:24:2880
for i = (j):(j+23)
E_load2(i) = E_load(i)+EV_load(i)-E_pv2(i);
if E_load2(i) < Allowed_summer
if E_bat < E_bat_max
charge = min(P_bat, (Allowed_summer-E_load2(i)));
E_bat = min(E_bat + charge*eff, E_bat_max);
E_load2(i) = E_load2(i)+charge;
E_bat2(i) = E_bat;
elseif E_bat == E_bat_max
E_bat2(i) = E_bat;
end
end
if E_load2(i) > Allowed_summer
if (0 < E_bat) && (E_bat <= E_bat_max)
charge = min([P_bat, (E_load2(i)-Allowed_summer), E_bat]);
E_bat = E_bat-charge;
E_load2(i) = E_load2(i) - charge;
E_bat2(i) = E_bat;
end
end
end
end
for i = time
if E_load2(i) ~= Allowed_summer
overload = overload +1;
end
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Solar Power에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by