Plotting DFT, figure not corresponding
4 ビュー (過去 30 日間)
古いコメントを表示
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')
0 件のコメント
回答 (1 件)
KALYAN ACHARJYA
2021 年 2 月 19 日
編集済み: KALYAN ACHARJYA
2021 年 2 月 19 日
"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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!