A doubt in ZERO PADDING IMPLEMENTATION

5 views (last 30 days)
actually i am applying short time fourier transform and i am implementing zero's to the end of the signal to match with the window length but i can see some artifacts in my plot with less power how can i avoid it can i avoid it by applying zeros between the signal like ex: 102030..... how can i do it.....

Accepted Answer

Image Analyst
Image Analyst on 28 Jan 2012
Not sure I follow why you're trying to do this, but here is code for interleaving zeros in your array:
m = rand(1,10); % Sample data.
interleaved = zeros(1, 2*length(m));
interleaved(1:2:end) = m
  1 Comment
raj
raj on 28 Jan 2012
I wanted to do this because when I add zeros to the nd of my signal I have some artifacts generated on my spectrogram so I wanted to try by adding zeros this way

Sign in to comment.

More Answers (1)

Wayne King
Wayne King on 29 Jan 2012
Raj, You don't want to insert zeros as you have done. That is called upsampling by two. Upsampling by two contracts the spectrum of the input signal by a factor of two and results in imaging artifacts.
As a simple example:
n = 0:99;
x = cos(pi/2*n);
y = upsample(x,2);
xdft = fft(x);
xdft = xdft(1:length(x)/2+1);
freq = 0:(2*pi)/length(x):pi;
plot(freq,abs(xdft));
hold on;
freq1 = 0:(2*pi)/length(y):pi;
ydft = fft(y);
ydft = ydft(1:length(y)/2+1);
plot(freq1,abs(ydft),'r');
set(gca,'xtick',[pi/4 pi/2 3*pi/4])
The original sine wave at pi/2 radians/sample has contracted to pi/4 radians/sample and a new "image" has appeared at 3*pi/4.

Community Treasure Hunt

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

Start Hunting!