How to cumulatively subtract in a specific range
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!