2017-03-31 18 views
0

私は伝達関数のボード線図をグラフ化しました。水平/垂直線を挿入してゲイン/位相角または周波数の特定の値を表示する方法があるかどうか疑問に思っていました?Matlabのボード線の垂直線

私は位相角グラフ上の水平線を引くことができ、次のコードを発見した

x = linspace(10^-1,10^2,100); 

for bleh = 1:length(x) 
     y(bleh) = -30.9638; 
end 

bode(num, den) 
hold on 
plot(x,y) 

をしかし、これはゲイングラフに適用するように見える、また私の限られた知識を行い(だけはありません私には意味をなさない道)の垂直線。私は試した:

y1 = get(gca,'ylim'); 
w1 = 1.2; 

bode(num, den) 
hold on 

plot(x,y,[w1 w1],y1) 

私は上記のコードから行われた1つの水平線を取得します。 これは可能でしょうか?

(それが重要ならば、R2017aを使用する。)

答えて

2

私は私はあなたが疑問に理解しましたわからないんだけど、それにもかかわらず、私は次のことを提案します。あなたが特定のaxes(または全ての中)で何かを追加したい場合には、ボード線図の場合のように多くの1 axesは、図にある

あなたはplotへの呼び出しでは、指定する必要がありますaxesのハンドルだから、

、ボード線図にラインを追加するために、あなたは2 axeshandlesを識別するために最初に持っている:あなたはそれを行うことができ、少なくとも二つの方法:findobj機能を使用して

  • ax=findobj(gcf,'type','axes')
  • 図のChildrenとして、それらを抽出します。ax=get(gcf,'children')

あなたがaxeshandlesを持っていたら、CA nは、追加する行の範囲を制限するために使用できるXLimYLimを取得します。

次の例では、上記の方法を使用して、各グラフに2行を追加しました。

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

enter image description here

希望、

Qapla」

+0

ありがとうございます!私は軸が別々であるとは考えていませんでした。明確で簡潔な;とても有難い! – Asinine

+0

あなたは大歓迎です!私はあなたに慣れてきました。 –

関連する問題