Reputation: 19
How can I plot the Fourier transformation of a wav
sound without using FFT
?
I take rectangle windows with size 256
on the whole signal.
Following is my code:
My code:
[wave,fs]=wavread('.\Sound clip 32.wav');
sound(wave,fs);
t=1:1/fs:length(wave)-1/fs;
plot(t,wave);
n=length(wave)-1;
for l=1:n,
x(l)=0;
end
for i=1:n,
for h=1:256,
x(i)=x(i)+wave(h)*(exp(-(j*2*pi*i*h)/n));
end
end
f=1:fs/n:n;
wavefft=abs(x);
plot(f,wavefft);
but I get this error
Error:
??? Error using ==> plot
Vectors must be the same lengths.Error in ==> alirezabahrami at 8 plot(t,wave);
How can I resolve this problem?
Upvotes: 0
Views: 292
Reputation: 688
The first plot error is caused by t
and wave
being different lengths. You could truncate the longest of those two and then plot, but in any case, t
is simply a linearly increasing vector, so you can just write
plot (wave)
and it will display the same thing, ie., your audio wave.
If you write plot(t)
you will just get a diagonal line.
further down you have the exact same problem, so just write:
plot(wavefft)
Upvotes: 2