Plotting DFT, figure not corresponding

4 visualizaciones (últimos 30 días)
Artur Kastro
Artur Kastro el 19 de Feb. de 2021
Editada: Artur Kastro el 19 de Feb. de 2021
I am plotting the real and imaginary parts of the base functions of DFT.
N = 40;
for k = (0:3)
x = exp(-j*2*pi*(k/N)*[0:N-1])
end
figure
plot (real(x), 'b')
xlabel('Sample number')
ylabel('Amplitude')
hold on;
plot (imag(x), 'r')
hold on;
legend('Real','Imaginary')
No issues there, but when it comes to the plot figure, I get:
At k = 0, shouldn't my cosine wave amplitudes be 1 and sine A at 0? Why the gap on the plot? I think the issue is that im multiplying by zero here: [0:N-1], but how do I go about fixing it in a most convinient way?
Edit: Got fixed, proper way is to define the x axis, like: plot ((0:N-1),real(x), 'b')

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 19 de Feb. de 2021
Editada: KALYAN ACHARJYA el 19 de Feb. de 2021
"Ak k = 0, shouldnt my cosine wave amplitudes be 1 and sine A - 0? "
The shown graph for k=3 only
Because you are not storing x values for all iterations. So this results from the last k value which is 3. Use figure and plots functions within the loop to see three results windows for k=1 to 3.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by