vertical line in plot

2 ビュー (過去 30 日間)
Jambo
Jambo 2017 年 10 月 31 日
コメント済み: Fangjun Jiang 2017 年 10 月 31 日
but i receive an error message, any help?
Also, how do i label the line?
  1 件のコメント
Jambo
Jambo 2017 年 10 月 31 日
this is the error: Undefined function 'vline' for input arguments of type 'double'.

サインインしてコメントする。

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2017 年 10 月 31 日
I don't think vline() is a MATLAB built-in function. You can use line() though.
x=100*(1:10);
y=1000*(1:10);
semilogx(x, y);
line([300 300],[2000,6000]);
  2 件のコメント
Jambo
Jambo 2017 年 10 月 31 日
thanks, how do i label the line?
Fangjun Jiang
Fangjun Jiang 2017 年 10 月 31 日
You can use text(). FYI, you may get the vertical line you wanted by adding "grid on". You may also consider xlabel()

サインインしてコメントする。


Star Strider
Star Strider 2017 年 10 月 31 日
編集済み: Star Strider 2017 年 10 月 31 日
You did not post your complete code.
The bode function generally allows you to make only a small number of modifications, all of which are listed in the documentation for it.
The easiest way to do what you want is to get the outputs from bode, then plot them as normal subplots. To label the vertical line, use the text function.
Example
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
[mag,phase,wout] = bode(H);
figure(2)
subplot(2,1,1)
semilogx(wout, squeeze(mag))
hold on
plot([1 1]*5, ylim, '--r')
hold off
text(5, mean(ylim), '\leftarrow \omega = 5')
grid
subplot(2,1,2)
semilogx(wout, squeeze(phase))
hold on
plot([1 1]*5, ylim, '--r')
hold off
text(5, mean(ylim), '\leftarrow \omega = 5')
grid
EDIT Added text calls to label the line.

カテゴリ

Help Center および File ExchangePlot Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by