Dear all,
the situation is the following: I have a projectlength of 3 years with an assumed number of hours of 10. For each hour the yield is calculated with a certain function (which I simplify in this example with the number 2). As the projectlength and hournumber should stay variable, I would like to first calculate the yield in each hour of the year (helper(k)) and then append the solutions of each projectyear below each other. So the yield should look like this:
I got the following so far, however, it does not work.
hournum = 10;
projectlength = 3;
yield = [];
for p=1:projectlength
for k = 1:hournum
helper(k)=2;
end
yield(p) = [yield(p); {helper(k)}];
end
Error Message: Index exceeds the number of array elements (0).
2 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/719850-how-to-append-for-each-iteration#comment_1269490
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/719850-how-to-append-for-each-iteration#comment_1269490
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/719850-how-to-append-for-each-iteration#comment_1269550
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/719850-how-to-append-for-each-iteration#comment_1269550
Sign in to comment.