[x,fs,bits]=wavread('piano');      % get the sound file（two-channel，16bit，44100Hz）
sound(x,fs,bits);                % play the sound
N = 4096;
y=fft(x,N);                      % FFT 
mag=abs(y);   
n=0:N-1;
t=n/fs;
f=n*fs/N;

plot(f(1:N/2),mag(1:N/2));       % show the plot
xlabel('Frequency/Hz');
ylabel('Amplitude');
title('N=4096');
grid on;