A short and simple piece of Matlab code that can save you some time! This code will take your input signals and interleave it with zeros. This can be very helpful when you need to upsample your signal by two. (add zero's and interpolate the signal afterwards)
This code be easily modified to interleave more than just 1 sample for different upsample ratios.
function out = interleave_zeros(a) % Interleave vector with zeros. % Only 1D matrices are supported. % % Usage: b = INTERLEAVE_ZEROS(a); % % A is the vector that will have zeros inserted % B will contain the vector set A and the interleaved % zeros (twice the length) % % Author: sparafucile17 2/13/04 my_zeros = zeros(1, length(a)); out = matintrlv([a my_zeros],2,length(a));