Sampling a signal in Matlab

MATLAB

I have the next signal

$$x_1[n]= 1 \ |n|\leq N_1; \ 0 \ otherwise$$.

Now I am given some points of sampling of the frequency of the fourier transform of the above signal. \$\omega_0 =\frac{2\pi}{5}\$, and \$\omega=k\omega_0\$ for \$k=-2,-1,0,1,2\$.

Now I am defining a periodic signal \$x_2[n]\$, which is given by:

$$x_2[n]=\sum_{k=-2}^{2} a_k e^{jk 2\pi n /5}$$

Where \$a_k\$ is given by the synthesis formula:

$$a_k=\frac{1}{5} \sum_{-2}^{2} x_1[n] \exp(-jk\frac{2\pi}{5}n)$$

I want to plot \$x_2[n]\$ in the \$n\$ space, but I don't want to calculate the \$a_k\$'s by hand, is there a way to do this by matlab, I mean without writing the full expression in paper and then typing it in matlab?

Is there such functionality?

Thanks in advance.

Best Answer

What you have appears to be a Fourier series pair, over a very small number of samples.

Probably, by looking at the definition of the Fourier series (which may be different depending on the conventions you choose), and maybe a table of results in a mathematical handbook, you can solve this by inspection.

I'll call \$x_2[n]\$ the "time domain" signal and a[k] the "frequency domain" signal.

For example, when \$N_1 \ge 2\$ then you have a pure complex exponential in the frequency domain. Therefore you know you'll have a delta-function in the time domain.

If you considered the case \$N_1 = 0\$, you'd have a delta function in the frequency domain and you'd get a pure complex exponential in the time domain.

The case \$N_1=1\$ is slightly more complicated -- that gives a complex exponential windowed by a boxcar in the frequency domain. So you know you have a sinc() (possibly offset in time) in the time domain.

But your concern about the effort involved in "writing the full expression in paper" indicates you already know how to solve the problem and you are hoping there is a shortcut or easier solution. To me, working out these Fourier relationships on paper (carefully enough to be sure of the answer) would probably be more effort than just doing the calculation in Matlab.