storing loop values in a matrix
3 views (last 30 days)
Show older comments
Danish Nasir
on 25 Jul 2021
Commented: Danish Nasir
on 25 Jul 2021
I have a column 10x1. Now i have to perform loop operation 5 times (i=1:5). I want to save the results of each loop so that the final matrix should be 10x5. Pls suggest the code.
0 Comments
Accepted Answer
Walter Roberson
on 25 Jul 2021
N = 10;
iters = 5;
column = randi(9,N,1)
results_of_loop = zeros(N, iters);
for K = 1 : iters
results_of_loop(:,K) = column.^K / factorial(K);
end
results_of_loop
surf(results_of_loop)
More Answers (0)
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!