MATLAB: How to store values form a loop in a vector

loopstoringvalues

How do I store the values of my "y" output in a vector?
for n=(0:8);
a=n;
b=n-8;
if a=0
a=1;
else a=0;
end
if b=0
b=1;
else b=0;
end
d=(1/2)*a;
d1=(1/2)*b;
y=d+d1;

Best Answer

y(n+1) = d+d1;