tags:

views:

126

answers:

2

Hi there,

I have 2 800x1 arrays in Matlab which contain my amplitude vs. frequency data, one array contains the magnitude, the other contains the corresponding values for frequency. I want to find the frequency at which the amplitude has reduced to half of its maximum value.

What would be the best way to do this? I suppose my two main concerns are: if the 'half amplitude' value lies between two data points, how can I find it? (e.g. if the value I'm looking for is 5, how can I "find it in my data" if it lies between two data points such as 4 and 6?)

and if I find the 'half amplitude' value, how do I then find the corresponding value for frequency?

Thanks in advance for your help!

+2  A: 

You can find the index near your point of interest by doing

idx = magnitudes >= (max(magnitude)/2);

And then you can see all the corresponding frequencies, including the peak, by doing

disp(frequencies(idx))

You can add more conditions to the idx calculation if you want to see less extraneous stuff.

However, your concern about finding the exact frequency is harder to answer. It will depend heavily on the nature of the signal and also on the lineshape of your window function. In general, you might be better off trying to characterize your peak with a few points and then doing a curvefit of some kind. Are you trying to calculate Q of a resonant filter, by any chance?

mtrw
@mtrw: You probably meant idx = magnitudes <= (max(magnitude)/2);
yuk
A: 

If it's ok, you can do simple linear interpolation. Find segments where the drop occurs and calculate intermediate values. That will be no good, if you expect noise in the signal.

idx = find(magnitudes(2:end) <= (max(magnitudes)/2) & ...
    magnitudes(1:end-1) >= (max(magnitudes)/2));
mag1 = magnitudes(idx); % magnitudes of points before drop
mag2 = magnitudes(idx+1); % magnitudes of points after drop below max/2
fr1 = frequencies(idx); % frequencies just before drop
fr2 = frequencies(idx+1); % frequencies after drop below max/2
magx = max(magnitudes)/2; % max/2
frx = (magx-mag2).*(fr1-fr2)./(mag1-mag2) + fr2; % estimated frequencies

You can also use INTERP1 function.

yuk

related questions