Hello, for a final project I am doing a menu with the notes do, re and mi. The problem is that when I apply the Fourier transform fft, my spectrum looks very weird. Does anyone know if I'm doing anything wrong? Code: do=audioread('do.wav'); sound(do,44100) nota=audiorecorder(44100,16,1); disp('Grabando...') recordblocking(nota,4) disp('Listo.') bb=getaudiodata(nota); audiowrite('grabacion.wav',bb,88200) audio=audioread('grabacion.wav'); audiof=fft(audio); subplot(2,1,1); plot(audio) subplot(2,1,2); plot(audiof) sound(audio,44100) Image:

댓글 수: 2

Salvador Salas Bonilla
Salvador Salas Bonilla 2017년 11월 14일
Jan
Jan 2017년 11월 14일
Please format your code using the "{} Code" button, such that it is readable. Attach images directly in the forum using the "Image" button instead of an external file hoster. Thanks.

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2017년 11월 14일

0 개 추천

In the plot you posted, you are plotting the real and imaginary parts of the two-sided Fourier transform. You need to plot the magnitude (absolute value, using the abs function) instead.
A single-sided Fourier transform is easier to understand. See the documentation on the fft (link) function for details on correctly plotting a one-sided Fourier transform.

댓글 수: 2

Salvador Salas Bonilla
Salvador Salas Bonilla 2017년 11월 14일
It was this, thank you very much! This was my first question here so I didn't know how to paste the code properly.
Star Strider
Star Strider 2017년 11월 14일
As always, my pleasure!
No worries — we were all new here once.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2017년 11월 14일

1 개 추천

Did you read the documentation of fft. There you find an example for plotting:
Y = fft(audio);
L = length(audio);
FS = 44100;
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)

댓글 수: 1

Nuchto
Nuchto 2017년 12월 17일
Thanks for this. Why did you divide by the L (length) when taking the magnitude?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

질문:

2017년 11월 14일

댓글:

2017년 12월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by