フィルターのクリア

Incrementing a loop for the next set of values

2 ビュー (過去 30 日間)
Ritika Srinivasan
Ritika Srinivasan 2022 年 1 月 4 日
コメント済み: VBBV 2022 年 1 月 5 日
Hi,
I have an array of Pv generation data of size 8760x1 this is code I have :
poweredbypv=(zeros(size(8760)));
for i=1:24
if Egenpv(i) > Eelectrolyzer
poweredbypv(i)=Eelectrolyzer;
else
poweredbypv(i)=Egenpv(i);
end
end
I need this piece of code to run 8760 times but each time 'i' has to be incremented for the next set of 24 values for example when the loop runs the second time the values from 25 to 48 must be considered and so on.
I would appreciate any help
Thank you!

採用された回答

VBBV
VBBV 2022 年 1 月 4 日
poweredbypv=(zeros(size(8760,24)));
for j = 1: length(poweredbypv)
for i=1:24
if Egenpv(i) > Eelectrolyzer
poweredbypv(j,i)=Eelectrolyzer;
else
poweredbypv(j,i)=Egenpv(i);
end
end
end
Add another for loop and try as above.
  4 件のコメント
VBBV
VBBV 2022 年 1 月 5 日
For every j value it runs 24 values using i in for loops. So resulting matrix would be 8760 x 24 size
VBBV
VBBV 2022 年 1 月 5 日
You don't have to increment it separately as the for loop with j is meant for it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by