banner



How To Draw Bode Plot In Matlab

I'm not sure I've understood you question, nevertheless, I propose the following.

When there are more one axes in a figure, as it is the case of the bode diagram, if you want to add something in a specific axes (or in all) you have to specify, in the call to plot the handle of the axes.

So, to add lines in the bode diagram, you have first to identify the handles of the two axes: you can do it in, at least two way:

  • using the findobj function: ax=findobj(gcf,'type','axes')
  • extract them as the Children of the figure: ax=get(gcf,'children')

Once you have the handles of the axes, you can get their XLim and YLim that you can use to limit the extent of the line you want to add.

In the following example, I've used the above proposed approach to add two lines in each graph.

The horizontal and vertical lines are added in the middle point of the X and Y axes (problably this point does not have a relevant meaning, but it is ... just an example).

          % 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])                  

enter image description here

Hope this helps,

Qapla'

How To Draw Bode Plot In Matlab

Source: https://stackoverflow.com/questions/43151134/vertical-lines-for-bode-plots-in-matlab

Posted by: burnsyoudly.blogspot.com

0 Response to "How To Draw Bode Plot In Matlab"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel