Matlab doesn't recognise the function dtf

Hey guys,
MATLAB doesn't seem to recognise the function dtf, any ideas on what to do? This is my code so far.
Any help would be amazing.
Annabell
n = [0:1:99];
x = cos(0.48*pi*n)+cos(0.52*pi*n);
n1 = [0:1:9];
y1 = x(1:1:10);
subplot(2,1,1);
stem(n1,y1);
title('signal x(n), 0 <= n <= 9');
xlabel('n')
Y1 = dft(y1,10);
magY1 = abs(Y1(1:1:6));
k1 = 0:1:5;
w1 = 2*pi/10*k1;
subplot(2,1,2);
stem(w1/pi,magY1);
title('DTFT Magnitude');
xlabel('frequency (pi)')

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 6 月 14 日
編集済み: Ameer Hamza 2020 年 6 月 14 日

0 投票

In MATLAB, DFT of a signal can be calculated using fft() function: https://www.mathworks.com/help/matlab/ref/fft.html. FFT is an efficient algorithm to calculate DFT.
Y1 = fft(y1,10);

1 件のコメント

Annabell Bennett
Annabell Bennett 2020 年 6 月 14 日
Worked perfectly.
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFourier Analysis and Filtering についてさらに検索

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by