Need help getting my delta functions to work
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to take the Fourier transform of two delta function but I'm having a problem with writing the code for my delta functions. The two functions are x = [1,0,0,0,....,0,0,0]; n=0...nfft-1 and y = x = [0,0,0,1,....,0,0,0]; n=0...nfft-1. The length of my fft (nfft) is 150. So far what I have is
nfft = 150;
x = [1,0,0,0:0:nfft-1];
y = [0,0,0,1,0:0:nfft-1];
but my vectors are x = [1,0,0] and y = [0,0,0,1]. They should be x = [1,0,0,.....0,0,0] and y = [0,0,0,1,0,0.....,0,0,0] from n=0 to nfft-1.
0 个评论
采纳的回答
Paul
2021-10-15
The problem is that
nfft = 150;
0:0:nfft-1
is empty. What that line is bascially asking for is a vector of number from 0 to 149 in increments of 0, which doesn't make sense, hench the empty result. If I understand the question correclty, you really want this
x = zeros(1,nfft);
x(1) = 1;
y = zeros(1,nfft);
y(4) = 1;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!