"Max " <mshestov@gmail.com> wrote in message news:ks201c$bok$1@newscl01ah.mathworks.com...> Hi guys, I'm having a bit of a brain fart here.>> Say you have a matrix A = [1,2,3,4,5]> and a logical vector B = [1,0,0,1,1,1,0,1]>> Where I want to stretch A to the Length of B by inserting 0's where 0's > locations appear in B.>> Basically, how can I turn matrix A into this [1,0,0,2,3,4,0,5] using B>> Appreciate the help guys.>> -Max>