How can I extract the x and y values of the phase- and magnitude graph of a .fig file plotted with bodeplot() or bode()?

6 次查看(过去 30 天)
I got a myBodeplot.fig file with two subplots and want to extract the x and y values for magnitude and phase.

采纳的回答

Paul
Paul 2023-12-16
编辑:Paul 2023-12-16
sys = tf(1,[1 1]);
bode(sys);
hf = gcf;
hax = hf.Children
hax =
3×1 graphics array: ContextMenu Axes Axes
hax(2).Children % the first child is the phase plot
ans =
2×1 graphics array: Group (sys) Line
hax(2).Children(1)
ans =
Group (sys) with properties: Children: [1×1 Line] Visible: on HitTest: on Use GET to show all properties
hax(2).Children(1).Children
ans =
Line with properties: Color: [0 0.4471 0.7412] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1.0000e-20 2.0000e-17 2.0000e-12 2.0000e-08 2.0000e-05 0.0020 0.0200 0.0234 0.0273 0.0320 0.0374 0.0437 0.0511 0.0598 0.0699 0.0818 0.0956 0.1118 0.1308 … ] (1×63 double) YData: [0 0 -1.1459e-10 -1.1459e-06 -0.0011 -0.1146 -1.1458 -1.3398 -1.5666 -1.8318 -2.1418 -2.5042 -2.9277 -3.4225 -4.0005 -4.6754 -5.4629 -6.3811 -7.4508 -8.6949 … ] (1×63 double) ZData: [1×0 double] Use GET to show all properties
w = hax(2).Children(1).Children.XData;
phase = hax(2).Children(1).Children.YData;
figure
semilogx(w,phase),grid
Note that bode keeps reasonable limits on the frequency axis
figure
semilogx(w,phase),grid
xlim([0.01 100])
Repeat for magnitude plot.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Plot Customization 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by