"Haitham Tahbub" <the_mummy_n1@hotmail.com> wrote in message <hu6lka$oc7$1@fred.mathworks.com>...
> i have a vector of size 20000 X 1 of 20000 elements inside
>
> i want to add 512 zeros between every 512 elements
>
> so after the first 512 elements i want to add 512 zeros and then the second 512 elements in the signal and then 512 zeros and so on till the end of the signal so the signal will be of length 40000
>
> i used this function
>
> xr = reshape([x zeros(length(x),512)]',513*length(x),1)
>
> but this function add 512 zeros between every two elements and the produced signal will be of length 513 *20000 = 10260000 elements !!!!!
>
> ANy SOlutions ????
> please Reply if you can help me
> Regards
> Haitham
Haitham, your arithmetic seems a bit faulty. The number 20000 is not divisible by 512, so after inserting 39 sets of 512 zeros, there will be 32 more left over from the original vector, and this would give you a total length of 20000+39*512 = 39968 elements, not 40000. Is that the result you want?
If so, calling the original vector x,
n = floor(20000/512);
xr = [reshape([reshape(x(1:512*n),512,n);zeros(512,n)],[],1);x(512*n+1:end)];
Roger Stafford
