How to add a vector to another vector in for loop
이전 댓글 표시
Hi,
I have a code calculating hourly temperatures in a system over a year in a for loop i=1:8760 (8760 is the number of hours in a year).
I would like to see how the hourly temperature level develop over ten years. I was thinking to put my already existing code into a new for loop with j=1:10, but I struggle with how wrap it up to a long vector with 87600 elements at the end. (not taking leap years into account). The code at this point is like this:
years=10;
T_tot=zeros(years,1);
for j=1:years
for i=1:8760
Tvec(i)=%code
end
T_tot(j)=Tvec;
end
I see that my code have some issues as I add several elements to my yearsx1 vector. How can this be improved so that i get my hourly values over 10 years (1x87600 or opposite)?
답변 (1개)
Alan Stevens
2020년 5월 29일
0 개 추천
One way is to replace T_tot(j)=Tvec; by T_tot((j-1)*8760+i)=Tvec;
카테고리
도움말 센터 및 File Exchange에서 Dynamic System Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!