Created
November 27, 2012 13:05
-
-
Save yassersouri/4154139 to your computer and use it in GitHub Desktop.
DTFT in matlab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ X ] = dtft( x, n, w ) | |
% [X] = dtft(x, n, w) | |
% X = DTFT values computed at w frequencies | |
% x = finite duration sequence over n | |
% n = sample position vector | |
% w = frequency location vector | |
temp = w' * n; | |
temp = -1i * temp; | |
e = exp(temp); | |
X = e * x'; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
w = -2*pi:0.01:2*pi; | |
n = 0:1:100; | |
w0 = 2; | |
x = exp(n .* (1i*w0)); % x = exp(jw0n) | |
X = dtft(x, n, w); | |
subplot(2,1,1); plot(n, x); title('signal = exp(jw0n)'); | |
subplot(2,1,2); plot(w, X); title('DTFT'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What I wanted to achieve in the implementation of DTFT was not using `for` loops. | |
Looking at the example it must be clear how to use this function. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
help me to solve this problem...