How to add a vector to another vector in for loop
Afficher commentaires plus anciens
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)?
Réponses (1)
Alan Stevens
le 29 Mai 2020
0 votes
One way is to replace T_tot(j)=Tvec; by T_tot((j-1)*8760+i)=Tvec;
Catégories
En savoir plus sur Dynamic System Models dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!