Adding tick marks without overriding existing marks

13 ビュー (過去 30 日間)
Andrew Jones
Andrew Jones 2016 年 12 月 3 日
コメント済み: Andrew Jones 2016 年 12 月 4 日
I would like to add a tick mark to a semilogx() plot to indicate the -3dB point of my transfer function. I know that I can use (gca,'XTick',[ ... ]) to add tick marks at specific frequencies; however, this forces the plot to ONLY display my specified tickmarks and completely removes the existing grid. is there anyway to add a tick mark overlay that maintains the standard semilog grid?
Note: the professor for this class had figures in his notes that do what I would like to do, but he has a pretty strict no-contact policy during take-home-exam weekends.

採用された回答

Stephen23
Stephen23 2016 年 12 月 3 日
Play around with this:
>> x = 5.7;
>> yV = get(gca,'ylim');
>> text(x,yV(1),num2str(x),'VerticalAlignment','top','HorizontalAlignment','center')
>> line([x,x],yV)
  1 件のコメント
Andrew Jones
Andrew Jones 2016 年 12 月 4 日
This works great, thank you!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 12 月 3 日
current_ticks = get(gca, 'XTick')
new_ticks = [current_ticks, specific_frequencies];
set(gca, 'XTick', new_ticks);
Or you can line() at the appropriate location, passing in 'Clipping', 'off') if you want the tick line to be visible outside the drawing area.
  2 件のコメント
Andrew Jones
Andrew Jones 2016 年 12 月 3 日
編集済み: Andrew Jones 2016 年 12 月 3 日
Not quite what I'm looking for. Additionally, this only works if the specific_frequencies are greater than every element of current_ticks. I tried line(), but apparently I don't have a firm enough understanding of that particular function.
I've attached a picture of what I am wanting to achieve. The plot has a user-defined tick at 5.7 degrees, but all of the dotted grey lines from the semilogx grid are still present. I have tried manually ticking for each of the standard semilog ticks, but then they all come out solid instead of dotted and it's harder to find the frequency I actually want to draw attention to.
Walter Roberson
Walter Roberson 2016 年 12 月 3 日
If it complains about the order then sort() new_ticks

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

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by