How to cumulatively subtract in a specific range
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!