Help plotting signal time shifted using FFT
显示 更早的评论
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!
采纳的回答
更多回答(1 个)
Umar
2024-7-8
0 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Time-Frequency Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!