First, I apologize for the repost, I got really confused how Stack Exchange works. I tried my best to improve the question!
Anyhow - I'm fairly new to the world of DSP, and I'm struggling with finding a way to plot the frequency spectrum of a discrete signal I calculated, described by
$$x(k) = 4 \left(\frac{\sin(4\pi k/6)}{4\pi k/6}\right)^2$$
with $x(0)=2$
using Matlab.
I have so far tried 4 different solutions, only one of which looks plausible, but I'd like to be sure. I know it's probably solved using the fft function, but I can't quite put it together.
Could someone help me figure this out? It'd be greatly appreciated!
Edit: As kindly suggested - and I really should have thought of it -- this is the Matlab code I'm currently working with:
k = -12:12;
x_k = 4 * (sin(4 * pi * k / 6) ./ (4 * pi * k / 6)).^2;
x_k(k == 0) = 2;
X_f = fftshift(fft(x_k));
f = linspace(-0.5, 0.5, length(k));
figure;
stem(f, abs(X_f), 'filled');
title('Frequency Spectrum of the Discrete Signal x(k)');
xlabel('Frequency');
ylabel('Magnitude');
grid on;
And this is a picture of the resulting spectrum: