Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Find minimum of variable by altereing two variables.

조회 수: 4 (최근 30일)
Nils Norlander
Nils Norlander 2017년 2월 28일
마감: Sabin 2025년 7월 7일
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개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by