Juan Felipe Ocampo Rodruez-
> Hi, I'm working on my Thesis and part of it is
the identification of
> frequencies in a .wav file, using a function generator with a 90Hz
> signal and using matlab with my program I'm supposed to get a
> variable called fre with 90 and another one (valor) with 1, this
> tells me that I have a signal of 90Hz, but it appears something
> completely different it says 281 and 1
It appears you are basing your concept of "frequency" only on the bin
position of FFT results. You've made no association with the actual
sampling rate of the data in the .wav file.
I haven't looked at your code closely other than to scan for sampling
rate
reference, but in general if FFT size = N and you have an FFT magnitude
index i ranging from 2 to N/2, then:
freq = i/N * Fs
where Fs is sampling rate in Hz. Here is a place to look for .wav header
info:
http://www.signalogic.com/ms_waveform.htm
-Jeff
> Here is my code:
>
> [x] = wavread('C:\Disco D\Crasher\UDLA\9no
> Semestre\Tesis\Muestras\Generador Funciones\91 520 560mv b', [1
> 360]);
>
> %Transformada de Fourier a [x]
> x1 = fft(x);
>
> %Hacer el vector so de magnitud.
> magx1 = abs(x1);
>
> %Sacar la mitad
> n = round(length(magx1)/2);
>
> %Quitar la mitad de la derecha del vector.
> vmagx1 = magx1(2:n);
>
> %Valor mimo del vector.
> vmaxmagx1 = max(vmagx1);
>
> %Normaliza con el valor mimo del vector.
> nx1 = vmagx1/vmaxmagx1;
>
> %Ciclo que compara las frecuencias que tienen una amplitud mayor a
> tol
> k=0;
> tol = .30;
> for i=2:length (nx1)
> if nx1(i)>tol
> k=k+1;
> fre(k)=i;
> valor(k)=nx1(i);
> end
> end