Like C or Python, but unlike Matlab or R, when you write s = sT, s is a reference to the same array as sT, so if you change one, you change both – since they are the same array. If you want to make a copy, you can explicitly make a copy: s = copy(sT). If the matrix you are copying is all zeros, you're probably better off just make a new array of zeros than copying the other one.
On Wed, Mar 5, 2014 at 12:15 PM, Jason Solack <jaysol...@gmail.com> wrote: > Hello everyone, i have some code that loops quite a bit. I have set up > before the loop begins a template array of zeros > > sT= zeros(Float64,1000) > > then within my loop i'm setting an array s = sT > > s=sT > > i'm then doing a bunch of work with the s array... at the top of the loop > i'd like to "zero out" the array without reinitiallizing it. After an > iteration my sT array has values in it and i don't see any reason why that > would happen. > > Any ideas how these values are being put into my sT array? > > Thank you! > > Jason >