I have some code below, the problem I'm having is that I want to output each iteration into the cell array P_SUM, and not just the final one. I'm not sure if I understand how for loops work, but I'm hoping it runs through the whole code in order (from the first for to the last end) before starting over. The way I'm currently doing it is by copying the whole code 40 times and changing the value of 'y', which I'm sure is not the most efficient way to do it. xs_current is a cell array containing 40 arrays of different sizes, I've attached it to this post aswell.
EDIT: It might be abit unclear on what the code is supposed to do; so I'll try to explain it in a simpler way. The first 'for' is supposed to choose what array of xs_current to use The second 'for' uses a function to compute the outputs of the function for all values of the array chosen previously The third 'for' sums all the outputs produced previously and outputs them into an array. Finally, the array produced in the third 'for' is supposed to be stored in a cell array, with the position defined by the first 'for'.
Best Answer