2015-04-06 99 views
0

有人可以告訴我最後一個劇情指令如何在後續劇本中起作用?Plot in child(Matlab)

close all; 
s=tf('s'); 
sys1 = 5/(s+5); 
sys2=exp(-1*s); 
G=ss(sys1)*ss(sys2); 
opts = bodeoptions('cstprefs'); 
opts.Grid= 'ON'; 
% create a figure and get the handle of the figure 
figHnd = figure; 
bode(G,opts) 
% get and display the children handles of the figure 
childrenHnd =get(figHnd, 'Children'); 
% select magnitude plot and plot a line 
axes(childrenHnd(3)); 
hold on; 
plot([1 1], [-20 20], 'r') 
hold off; 

我試圖爲截止頻率的水平線添加到我的波特圖(幅度圖),但我無法弄清楚如何做到這一點。當前的代碼爲我添加了一條垂直線。

回答

1

的問題是關於線

plot([1 1], [-20 20], 'r') 

這是一個簡單的繪圖命令。一般情況下,你使用

plot(x,y) 

這裏是相同的:x維矢量是[1, 1]y維矢量爲[-20, 20]。所以你畫了一條從(1,-20)(1,20)的線。最後一部分(r)僅指定顏色,即紅色。這正是你可以在波特圖中看到的。

要創建一條水平線,例如從(10^-1, -20)(10^0, -20)可以得出相若方式

plot([10^-1, 10^0], [-20, -20], 'r'); 

(不要忘了把它內hold on; ... hold off;,所以波特圖也不會消失。

+0

更深入的比其他的答案。+1。 – rayryeng 2015-04-06 14:54:43

0

變化類似於此的最後一個陰謀代碼:

plot([1 10], [-20 -20], 'r') 

參考plot和一些例子努力得到它是如何工作的想法。