Help plotting signal time shifted using FFT
Ältere Kommentare anzeigen
Hi! This is my first Matlab project and first question here, so it might be some simple syntax error I'm not getting. Yes it's a school project so I can't use built-in functions.
I'm trying to use a DFT matrix to convert a signal (rectangle function), and then multiplying it by an exponent. This, when converted back, should give me a time shifted signal. Instead, I get the original signal (unshifted). This is the code:
N = 2001; %period
middle = floor((N-1)/2);
ts = -middle:middle;
fs = -middle:middle;
dft_matrix = (1/N)*exp(-1i*2*pi*fs'*ts/N);
idft_mtx = exp(1i*2*pi*fs'*ts/N);
a = zeros(N,1);
a(middle-100:middle+100) = 1;
ak = dft_matrix*a;
bk = exp(-1i*2*pi*100/N).*ak;
b = idft_mtx * bk;
plot(ts,b)
I'd appreciate tips how to make the code better :)
Thank you!
Akzeptierte Antwort
Weitere Antworten (1)
Umar
am 8 Jul. 2024
0 Stimmen
Hi Guilhermo,
I am pleased to hear that the solution provided worked for you. If you have any further questions or need assistance in the future, please do not hesitate to reach out.
Kategorien
Mehr zu Time-Frequency Analysis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!