Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Frequency (Hz) and measured linear gain (unitless)
- f = [610, 1220, 3050, 4270, 5490, 6100, 7320, 12200, 24400, 36600, 61000].';
- G = [1.5, 1.48, 1.38, 1.32, 1.1, 0.98, 0.73, 0.34, 0.09, 0.04, 0.02].';
- % Convert to magnitude in dB
- GdB = 20*log10(G);
- % Bode-style magnitude plot (frequency log scale)
- figure;
- semilogx(f, GdB, '-o', 'LineWidth', 1.5, 'MarkerSize', 6);
- grid on;
- grid minor;
- xlim([min(f)*0.9, max(f)*1.1]);
- xlabel('Frequency (Hz)');
- ylabel('Magnitude (dB)');
- title('Measured Bode Magnitude Plot');
- % Optional: annotate corner-like points (e.g., where gain crosses 0 dB)
- zcrossIdx = find(diff(sign(GdB))~=0, 1, 'first');
- if ~isempty(zcrossIdx)
- % Linear interpolation of zero-crossing on log-frequency axis
- x1 = log10(f(zcrossIdx)); y1 = GdB(zcrossIdx);
- x2 = log10(f(zcrossIdx+1)); y2 = GdB(zcrossIdx+1);
- xz = x1 + (0 - y1)*(x2 - x1)/(y2 - y1);
- fz = 10^xz;
- hold on;
- plot(fz, 0, 'rs', 'MarkerFaceColor', 'r');
- text(fz, 0, ' 0 dB crossing', 'VerticalAlignment', 'bottom');
- end
Advertisement
Add Comment
Please, Sign In to add comment