How to save the values after each iteration in a matrix ?

205 views (last 30 days)
Hello everybody ,
I did some calculation in a loop and this is the output I need to put the value after each iteration in Nx1 matrix how can I do this?
sumOfValues1 =
sumOfValues1 =
sumOfValues1 =
sumOfValues1 =

Accepted Answer

Adam Danz
Adam Danz on 13 Jul 2018
Edited: Adam Danz on 13 Jul 2018
Follow this example for n=6 loops where I store your sumOfValues1 in a n-by-1 vector. Also, take some time to read through this document so you understand how indexing works.
% initialize variable
n = 6;
a = zeros(n,1);
% Loop through and store result
for i = 1:n
a(i) = sumOfValues1;

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!