storing loop values in a matrix
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2021-7-25
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!