MATLAB: How can i keep the results of for loop iteration in every step

arraycreating arrayfor loop

I am trying to calculate a sum series. Series upper limit chance btw 4:2:16 and i want to keep for loop iterations in an array cause i will make a plot N vs Stot.
syms j
for N=4:2:16
S(i)=(symsum(cos((20*pi*j)/(N+1)),j,0,N))
Stot=(2*pi/(N+1))*S;
double(Stot)
end

Best Answer

use
slot(i)=(2*pi/(N+1))*S;
Example:
for i=1:10;
k(i)=2+i;
end
Command Window
>> k
k =
3 4 5 6 7 8 9 10 11 12