having the same problem about the arrays

조회 수: 2 (최근 30일)
Elisa
Elisa 2024년 10월 1일
댓글: Star Strider 2024년 10월 2일
daily_savings=zeros(1505,1);%initial saving vectors
daily_earnings=zeros(1505,1);%initial earning vectors
% Loop through each day to calculate savings and earnings % total days is 1505 (Date from(06/04/20 to 19/05/24))
for i = 0:1504 % days1 starts from 0 so 0:1504
% Calculate daily savings
daily_savings(i + 1) = O_Consumption(i + 1).*Cost;
% Calculate daily earnings
if i <= 1212 % Up to July 31, 2023 (day index 1212)
daily_earnings(i + 1) = energy_out(i + 1).*Feed(i + 1);
else % From August 1, 2023 onwards
if e_out(i + 1) < 10
daily_earnings(i + 1) = e_out(i + 1).*Feed(i + 1);
else
daily_earnings(i + 1) = ((e_out(i + 1) - 10) / 100) + 0.88;
end
end
above is the code

채택된 답변

Star Strider
Star Strider 2024년 10월 1일
My guess is that you actually want to calculate this:
daily_savings(i + 1) = O_Consumption(i + 1).*Cost(i+1);
Multiplying by the entire ‘Cost’ vector is likely throwing the error.
.
  댓글 수: 2
Elisa
Elisa 2024년 10월 2일
Thank you ! that is the problem
Star Strider
Star Strider 2024년 10월 2일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by