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일

0 개 추천

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일

0 개 추천

One more way to do it
x = 1:4;
x1 = cat( 1, x, zeros(size(x)) );
x1 = transpose(x1(:));

카테고리

태그

질문:

2012년 8월 16일

댓글:

2020년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by