MATLAB: Inserting space between values in vector

spacevector

Hi,
Say I have a vector x = [1 2 3 4] How can I make it x1 = [1 0 2 0 3 0 4 0]
Thank you!!

Best Answer

Do you have the Signal Processing Toolbox?
x = [1 2 3 4];
x = upsample(x,2);
If not
x = 1:4;
y = zeros(2*length(x),1);
y(1:2:end) = x;
If you have the Wavelet Toolbox
x = 1:4;
y = dyadup(x,0);