Using the output of one run of a function as the input of another iteration of that function
2 views (last 30 days)
Show older comments
Hi so I've a problem where I have made a function that adds neighbouring elements and reduces its size (i.e. 50 elements reduces to 25 after one run of the function). What I want to do is repeat the function until the size of the matrix is 1 so that I can output the final addition. I cannot wrap my head around the loops to use since I want the loop to use the output of the previous iteration as the input for the next iteration i.e. the next run of the same function. For example 50 -> 25 -> 13 -> 7 -> 4 -> 2 -> 1 elements
I was thinking something like this but it just repeats the first step (50 -> 25 -> 13) a load of times
Thank you for your help
for i = 1:Counter
outputv = ReduceArray(List)
inputv = ReduceArray(outputv);
end
0 Comments
Answers (1)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!