[問題] 找不出 FFT 的錯誤已回收
老師說,這串code有錯 可是我實在找不出來錯在哪裡 (問題一)
還必須要口頭解釋畫出來的兩個圖到底在model 什麼(問題二)
我嘗試著用註解解釋了一些,但是還不是很確定
希望有人能就這兩個問題 提供比較明確且詳盡的解答 謝謝
我花了五個小時在弄這個 可是還是不知道 再半天就要交了...
感覺 已經走投無路了 哭哭
真的希望有人能協助我 @@
function mysteryfunction
f0 = 261.625; %frequency of the wave
harm = 3.*f0; %the harmonic is in 3 times of the fequency
npts = 8192; %2^13; it's a power of 2
freq = linspace(-1e4,1e4,npts);
cspect = zeros(size(freq)); %generate a series of 0
%10 = bandwidth;
%compute the harmonic in both positive side and negative side
lv = (abs(freq - f0)<10)|(abs(freq+f0)<10);
lv2 = (abs(freq - harm)<10)|(abs(freq+harm)<10);
cspect(lv) = 1; %define the amplitude of a specific frequency shows on the
plot
cspect(lv2) = 0.25; %define the amplitude of the harmonic shows on the plot
ctime = fftshift(fft(fftshift(cspect))); %fourier transform using FFT
%tt = ((-npts./2):((npts./2)-1))./2e4; %frequency span = 2e4
tt = linspace(0,npts./2e4,npts); %time period
figure
subplot(2,1,1)
plot(freq,cspect,'-r') %shows where the two harmonics located (v.s frequency)
subplot(2,1,2)
plot(tt,real(ctime),'-r') %plot the undulation
xlim([-.02 .02])
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 128.151.87.122
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章