Inserting space between values in vector

1 回表示 (過去 30 日間)
Matlabbey
Matlabbey 2012 年 8 月 16 日
コメント済み: Emre Metin 2020 年 5 月 22 日
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!!

採用された回答

Wayne King
Wayne King 2012 年 8 月 16 日
編集済み: Wayne King 2012 年 8 月 16 日
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 件のコメント
Matt Fig
Matt Fig 2012 年 8 月 16 日
I learn something new everyday. I didn't know there was a function to do this! Thanks, Wayne.

サインインしてコメントする。

その他の回答 (1 件)

per isakson
per isakson 2012 年 8 月 16 日
編集済み: per isakson 2012 年 8 月 16 日
One more way to do it
x = 1:4;
x1 = cat( 1, x, zeros(size(x)) );
x1 = transpose(x1(:));

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by