0
$\begingroup$

I am using the following code to plot a window:

m = ((33-1)/2)
n = -m:m
w = 0.54 + 0.46 *cos(pi*n/m)
stem(0: numel(w)-1, w)

This is giving the following plot:

enter image description here

Now I tried zero-padding the window with 200. I used the following code:

m = ((33-1)/2)
n = -m:m
w = 0.54 + 0.46 *cos(pi*n/m)
w_zp = padarray(w, 200, 'pre')
stem(0: numel(w_zp)-1, w_zp)

Why is this not working please?

$\endgroup$
0
$\begingroup$

I've never used padarray, but for such a simple example you might as well use (assuming w is a row vector as in your code):

Npre = 100;    % # zeros before w
Npost = 100;   % # zeros after w
w_zp = [zeros(1,Npre), w, zeros(1,Npost)];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.