Filter löschen
Filter löschen

Find minimum of variable by altereing two variables.

3 Ansichten (letzte 30 Tage)
Nils Norlander
Nils Norlander am 28 Feb. 2017
Bearbeitet: dpb am 28 Feb. 2017
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

Antworten (0)

Kategorien

Mehr zu Power and Energy Systems finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by