Effacer les filtres
Effacer les filtres

How to cumulatively subtract in a specific range

2 vues (au cours des 30 derniers jours)
Benedikt Wessel
Benedikt Wessel le 21 Sep 2018
Hello everybody, how can I adjust my for loop so that every time when the curve is above the max capacity and negative (see some examples, shown by the arrows), the values will be cumulatively subtracted by the capacity (see the black curve). With my Code I calculate only the difference at one point, with no effect on the actual capacity... You can find my code below.
C=cumsum(diffE,'omitnan'); % needed Capacity
Cbmax= 1000; % in MWH, max. capacity of the battery storage
Cbmin= 100; % in MWh, deep charge border
imax= C>=Cbmax-Cbmin; % find where C is larger than Cbmax
imin= C<=Cbmin-Cbmin; % find where C is smaller than Cbmin
C(imax) = Cbmax-Cbmin; % if C is larger than Cbmax: C=Cbmax
C(imin) = Cbmin-Cbmin; % if C is smaller than Cbmin: C=Cbmin
Cres=cumsum(diffE,'omitnan');
for k=1:length(Cres)-1
if Cres(k)>Cbmax
if Cres(k)>Cres(k+1)
C(k+1)=C(k)-(Cres(k)-Cres(k+1));
end
end
end

Réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by