Q: Do I need to initialize matricies?

Sometimes it saves your time! If you know the maximum size that a matrix will be, create it that size initially, rather than letting it grow incrementally.

This fragment

 for p=1:1e4;
takes more than 5 seconds to finish.
While when you add a line
it takes only 0.08s!

(Anything that helps avoid memory re-allocation that happens at each iteration in the first example will work, e.g.:
- run the loop backwards
- use X(1e4,1)=0 to allocate the memory