How to save the values after each iteration in a matrix ?
244 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?
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;