samplingrate=90000
TotalDuration=10
//fundamental frequency of the sound signal
f0=200//hertz
t=0:1/samplingrate:TotalDuration
N=length(t)//number of samples to be taken from a sound signal
soundsignal=0.1*cos((2*%pi*f0)*t)+0.5*cos((2*%pi*2*f0)*t)//sound wave signal. This particular signal contains two frequencies 20hz and 40hz
//plot(t,soundsignal)
//Due to sampling some information of the signal is lost and with varying sampling rate you may hear different sounds (almost distinguishable)
playsnd(soundsignal)//plays the sound signal. You can listen to this signal without earphones or with volume down sufficiently.
[x]=fft(soundsignal)
figure(2)
f=(1:N)*(TotalDuration)^-1
plot2d3(f,abs(x))
//In fft you see that you get two peaks of varying amplitudes at frequencies 20 and 40 hz. Amplitudes are proportional to what you see in this signal (ideally one expects Dirac impulses with the area under them equal to amplitudes)).