0

I am trying to understand the zero-padding in frequency domain and discovered that original sequence in interpolated data only when (N/M) = integer where N and M are the lengths of output and input.

clear all;
close all;

M = 9; N = 18;

m_p = (M - 1) / 2;

x1 = [2 4 5 2 1 3 1 7 9];

y1 = fft(x1);

y2 = (N/M) * [y1(1:m_p+1) zeros(1, N-M) y1(m_p+2:M)];

z_c = N - M; z_f = 1 + (z_c-1) / 2 z_b = z_f - 1;

y3 = (N/M) * [zeros(1, z_f) (y1(m_p+2:M)) y1(1:m_p+1) zeros(1,z_b)]

x2 = ifft(y2, N)

x3 = ifft(y3, N)

Also, why zero-padding at the ends of the spectrum gives negatives values of interpolated data and positive of original sequence?

x2 =

2.0000 + 0i 2.1303 + 0.0000i 4.0000 - 0.0000i 5.2490 + 0i 5.0000 + 0i 3.6885 - 0.0000i 2.0000 + 0i 0.8029 - 0.0000i 1.0000 + 0.0000i 2.3184 + 0i 3.0000 - 0.0000i 1.9939 + 0.0000i 1.0000 + 0i 2.7335 - 0.0000i 7.0000 - 0.0000i 10.0992 + 0i 9.0000 + 0.0000i 4.9842 + 0.0000i

x3 =

2.0000 + 0i -2.1303 - 0.0000i 4.0000 - 0.0000i -5.2490 + 0i 5.0000 + 0i -3.6885 + 0.0000i 2.0000 + 0i -0.8029 + 0.0000i 1.0000 + 0.0000i -2.3184 + 0i 3.0000 - 0.0000i -1.9939 - 0.0000i 1.0000 + 0i -2.7335 + 0.0000i 7.0000 - 0.0000i
-10.0992 + 0i 9.0000 + 0.0000i -4.9842 - 0.0000i

jomegaA
  • 659
  • 3
  • 16

1 Answers1

1

I ... discovered that original sequence in interpolated data only when (N/M) = 2

Whatever you did, you did discover wrongly. Provided you zero-pad correctly, the original samples will be preserved whenever the ratio is an integer, i.e. $N/M \in \mathbb{I}$

If the ratio is not an integer, the new sample grid doesn't include the sampling times of the original samples, hence they cannot be preserved.

Also, why zero-padding at the ends of the spectrum gives negatives values of interpolated data and positive of original sequence?

Because you created a frequency shifted version of the correctly zero-padded spectrum. The shift is exactly half the sequence. This can be interpreted as modulating with a complex sine with a frequency of $N/2$, i.e.

$$x_{mod}[n] = e^{j2\pi\frac{N/2 \cdot n}{N}} = e^{j2\pi\frac{n}{2}} = e^{j\pi n} = (-1)^n $$

Hilmar
  • 44,604
  • 1
  • 32
  • 63