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!