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에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!