Borrar filtros
Borrar filtros

Inserting space between values in vector

3 visualizaciones (últimos 30 días)
Matlabbey
Matlabbey el 16 de Ag. de 2012
Comentada: Emre Metin el 22 de Mayo de 2020
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!!

Respuesta aceptada

Wayne King
Wayne King el 16 de Ag. de 2012
Editada: Wayne King el 16 de Ag. de 2012
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);
  1 comentario
Matt Fig
Matt Fig el 16 de Ag. de 2012
I learn something new everyday. I didn't know there was a function to do this! Thanks, Wayne.

Iniciar sesión para comentar.

Más respuestas (1)

per isakson
per isakson el 16 de Ag. de 2012
Editada: per isakson el 16 de Ag. de 2012
One more way to do it
x = 1:4;
x1 = cat( 1, x, zeros(size(x)) );
x1 = transpose(x1(:));

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by