필터 지우기
필터 지우기

How to cumulatively subtract in a specific range

조회 수: 2 (최근 30일)
Benedikt Wessel
Benedikt Wessel 2018년 9월 21일
편집: Benedikt Wessel 2018년 9월 21일
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개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by