MATLAB Answers


viewing spectrum of an audio signal in matlab

Asked by Bahareh
on 15 Oct 2011

Hello all,

I have an audio signal (.wav) and would like to view its spectrum in matlab. Can anybody help me in this manner?

Thanks in advance.


2 Answers

Answer by Wayne King
on 15 Oct 2011
 Accepted answer

Read it in with wavread()

[signal,fs] = wavread('file.wav');

If signal is Nx2 (two columns), extract one of them

signal = signal(:,1);

If you have the Signal Processing Toolbox, enter


  1 Comment

on 15 Oct 2011

Thanks a lot.

Answer by Ali Isik
on 15 Oct 2011

you should first read the audio signal using wavread() function. as a result of reading, the signal will be vectorized. after that, you should use fft() function to get the fourier transform of vectorized signal. at the end plot() the fourier transform of signal. sample code

[xn fs]=wavread('signal_name.wav');
nf=1024; %number of point in DTFT
Y = fft(xn,nf);
f = fs/2*linspace(0,1,nf/2+1);

  1 Comment

on 15 Oct 2011

Thanks a lot.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!