From: Lohique on
Hello .
Recently i learn to use matlab. I have tried to find a solution on internet but with any success.
I'm trying to find the magnitude on a wav file. I'm trying to "enslave" (overcome ?) my speakers with my microphone.
The main problem is the gestion of the magnitude ( i have divided by the initial pressure ) .I want to see how many db ( or dbs ) I have . That's my code :

% Extraction du fichier

[x,]=wavread('1500hz.wav');
fs = 44100;
%

%Construction des graphes

t=(0:length(x)-1)/fs; % times of sampling instants
subplot(2,1,1);
plot(t,x);
legend('sinus');
xlabel('Temps (s)');
ylabel('Amplitude');

%

% transformation de fourrier plus fenĂȘtre de hamming

Y=fft(x.*hamming(length(x)));

% Spectre max de 3000 hz

hz3000=3000*length(Y)/fs;

f=(0:hz3000)*fs/length(Y);

subplot(2,1,2);
z=20*(log10(abs(Y(1:length(f))/(2*10^-5))+ eps));
plot(f,z);
legend('Spectre');
xlabel('Frequence (Hz)');
ylabel('Amplitude (dB)');



Thank you for helping