# Keeping the length of vectors fixed

b and d are two arrays that are given. I create aa and cc out of b andd. This is what I do:

aa = {};
cc = {};

Do[If[j == 1,
AppendTo[aa, b[[i, j]]],
If[j == 2, AppendTo[cc, d[[i, j]]]]],
{i, 1, 9, 1}, {j, 1, 2, 1}]


With this code I create the two vectors of length 9. The problem is that each time I execute the Do again, the length of my vectors increase by 9. How can keep their length fixed at 9?

-
Can't you do aa = b[[1;;9, 1]] and similar ? – b.gatessucks Mar 7 at 9:54
Yes!!!Thanks b.gatessucks!!:) – Mencia Mar 7 at 9:57
Execute aa={};cc={}; (that is, reset aa and cc to empty set) before you execute Do[...]. But... why don't you use aa = b[[;;9, 1]];cc = d[[;;9, 2]];` instead? – kguler Mar 7 at 10:00