0

I need to calculate the 3dB bandwidth from data containing Power in dB vs Frequency in Hz. For instance:

X = 
    2.9640   -5.0568
    2.9705   -4.5819
    2.9770   -4.1277
    2.9835   -3.7016
    2.9900   -3.3095
    2.9965   -2.9560
    3.0030   -2.6446
    3.0095   -2.3776
    3.0160   -2.1569
    3.0225   -1.9839
    3.0290   -1.8596
    3.0355   -1.7847
    3.0420   -1.7596
    3.0485   -1.7849
    3.0550   -1.8609
    3.0615   -1.9877
    3.0680   -2.1655
    3.0745   -2.3944
    3.0810   -2.6741
    3.0875   -3.0044
    3.0940   -3.3843
    3.1005   -3.8126
    3.1070   -4.2872
    3.1135   -4.8051
    3.1200   -5.3616
    3.1265   -5.9505

I get the peak I am interested in with findpeaks builtin function:

[pks, locs, w, p] = findpeaks(X.data(:,2), 'MinPeakProminence',3);
fstpeak = locs(1);
frequency = X(fstpeak,1);
peak_magnitude = X(fstpeak,2);

I can obviously make a for loop and look forward and backward from fstpeak until I get a value of magnitude below peak_magnitude - 3, and then interpolate if more precision is required.

It seems a pretty common operation, but I have tried to find a builtin matlab function with no success. Is there a builtin function I can use, or a faster approach to the custom for loop?

1 Answer 1

3

I think your problem with doing this is going to be that your data is not monotonically increasing. Having said that, it does follow a nice curve - it rises to a maximum and then starts to decrease, and there is no noise. As such, you can split the curve in two shorter curves that are monotonically increasing/decreasing and use `interp1' to find the -3dB point.

frequency = X(:,1);
magnitude = (X:,2);
magnitude = magnitude - max(magnitude); % Normalise to maximum

indmax = find(magnitude == max(magnitude));

f1 = interp1(magnitude(1:indmax), frequency(1:indmax), -3);
f2 = interp1( magnitude(indmax:end), frequency(indmax:end), -3);
BW = f2 - f1;

This approach will fall down if you apply it to data that does not rise and then fall, or if you apply it to noisy data.

Sign up to request clarification or add additional context in comments.

1 Comment

I have the width of the peak in w parameter, so I can extract the points that constitute the peak, and split given its position. It seems a good solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.