I read that initialization of vectors ~~saves memory~~ speeds up execution time when running code in matlab, however I do not know how to do that in this case. 

I have a vector that I reuse and adds onto itself in a loop, so I should preallocate a vector that has the length of the ending vector. I have tried 

```
vec=zeros(1,n)

```

but that tacks on zeros to the start of the output matrix.

```
clc
clear
n=6
x=0
vec=x
    for i=1:n
        x=x+1
        vec=[vec,x]
    end
vec

```

Is there another way to initialize the 'vec' vector?

Now changed to:

```
clc
clear
n=6
x=0
vec=zeros(1,n) %changed from x=0
    for i=1:n
        x=x+1 
        vec(i)=x %changed from   vec=[vec,x]
    end
vec

```