What is the problem in this code?
1 view (last 30 days)
Shoaibur Rahman on 2 Jan 2015
Edited: Shoaibur Rahman on 2 Jan 2015
Your n has a length of 9, as n=0:8, so i will have length of 9 as well,and hence, you cannot write i(1:81). There are many ways to solve this. Here is one: replace n = 0:8 by n = linspace(0,8,length(f)). This will make both f and i of same length.
Also, although plot(f,abs(i(1:81))) works fine, but you can simply use plot(f,abs(i))
Another way may be: keep everything same, but write i = fft(xs,length(f)) . This will perform 81 point fft on xs. Again, you can use plot(f,abs(i))