[問題] 新手請教已回收

看板MATLAB作者 (愚人)時間14年前 (2009/10/20 17:09), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串1/2 (看更多)
程式碼 -------------------------- clear; mysong = 'song-8k.wav'; [x,fs,nbits] = wavread(mysong); subplot(6,1,1);plot(x); axis('tight');title('MySong'); subplot(6,1,2);specgram(x,128,8000); axis('tight');title('Spectrum of MySong'); for n =7:length(x) Moving =(x(n)+x(n-1)+x(n-2)+x(n-3)+x(n-4)+x(n-5)+x(n-6)); end subplot(6,1,3);plot(Moving); title('Moving average'); subplot(6,1,4);specgram(Moving,128,8000); title('Spectrum of Moving average'); --------------------------- 請教在Moving的部份,我希望將x經過疊加之後,存入Moving裡。 但Moving裡卻只有一個數值,為何不是一堆數值呢? 請大大們幫忙指教,何處有誤。謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.124.42.91

10/20 17:34, , 1F
因為你的Moving是單一變數 每個迴圈時都會被蓋過
10/20 17:34, 1F

10/20 17:42, , 2F
改成Moving(n)或Moving(n-6)
10/20 17:42, 2F

10/20 18:00, , 3F
試了,還是一樣耶。
10/20 18:00, 3F
文章代碼(AID): #1AtNux8w (MATLAB)
文章代碼(AID): #1AtNux8w (MATLAB)