我不确定我是否理解你的问题,不过,我提出以下建议。
当一个图中有多个axes时,就像波特图的情况一样,如果你想在特定的axes(或全部)中添加一些东西,你必须在调用中指定到plotaxes的句柄。
所以,要在波德图中添加线条,您必须首先识别两个axes 中的handles:您可以这样做,至少有两种方式:
- 使用
findobj函数:ax=findobj(gcf,'type','axes')
- 将它们提取为图中的
Children:ax=get(gcf,'children')
获得axes 中的handles 后,您可以获得它们的XLim 和YLim,您可以使用它们来限制要添加的行的范围。
在以下示例中,我使用上述建议的方法在每个图形中添加两条线。
在X轴和Y轴的中点加上横竖线(可能这个点没有相关意义,不过……只是个例子)。
% Define a transfer function
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
% PLot the bode diagram
bode(H)
% Get the handles of the axes
ax=findobj(gcf,'type','axes')
phase_ax=ax(1)
mag_ax=ax(2)
% Get the X axis limits (it is the same for both the plot
ax_xlim=phase_ax.XLim
% Get the Y axis limits
phase_ylim=phase_ax.YLim
mag_ylim=mag_ax.YLim
%
% Define some points to be used in the plot
% middle point of the X and Y axes of the two plots
%
mid_x=(ax_xlim(1)+ax_xlim(2))/2
mid_phase_y=(phase_ylim(1)+phase_ylim(2))/2
mid_mag_y=(mag_ylim(1)+mag_ylim(2))/2
% Set hold to on to add the line
hold(phase_ax,'on')
% Add a vertical line in the Phase plot
plot(phase_ax,[mid_x mid_x],[phase_ylim(1) phase_ylim(2)])
% Add an horizontal line in the Phase plot
plot(phase_ax,[ax_xlim(1), ax_xlim(2)],[mid_phase_y mid_phase_y])
% Set hold to on to add the line
hold(mag_ax,'on')
% Add a vertical line in the Magnitide plot
plot(mag_ax,[mid_x mid_x],[mag_ylim(1) mag_ylim(2)])
% Add an Horizontal line in the Magnitide plot
plot(mag_ax,[ax_xlim(1), ax_xlim(2)],[mid_mag_y mid_mag_y])
希望这会有所帮助,
卡普拉'