Bode plot
12 views (last 30 days)
Show older comments
Hi, Is there a way i can display the 3dB line on a bode plot and also display the frequency value at the point where the bode plot intersects the 3dB line?
0 Comments
Answers (1)
sco1
on 4 Nov 2011
Assuming you have the frequency and db vectors, you can find the intersection of your required line and back out its location on the plot. Once you do that, you can annotate your graph.
As an (oversimplified) example:
xoffset = a; yoffset = b;
[~,xi,~] = intersect(dB,3);
y(1:numel(freq)) = 3;
figure;loglog(freq,dB,freq,y);
text((freq(xi) + xoffset),(dB(xi) + yoffset),[num2str(freq(xi)) 'Hz'];
Where a and b are arbitrary constants to offset your text from the point so you can read it, might take a little fiddling to figure out. xi is the index for column where your magnitude equals 3dB, and this allows you to find the frequency.
The above is simplified to assume only one intersection. If there are multiple intersection points, a few lines of logic will need to be added to account for this, but the above is generic enough that it wouldn't take too much effort.
It also assumes that you have a data point in your dB vector with a magnitude exactly equal to 3 dB, which I'm guessing doesn't generally happen, but it would be pretty simple to search for an intersection using some specified tolerance.
The above is a generic example that I hope should help you tailor a script that suits your needs. It's probably not the most elegant solution because I'm not really an elegant coder, but I hope it helps set you in the right direction.
0 Comments
See Also
Categories
Find more on Plot Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!