Does changing the axes turn tick marks off?

I've tried to adjust my tick marks but they don't even exist anymore. Plenty of help on how to get rid of tick marks but absolutely nothing out there on how to turn them on. My code is listed below. The end of it is really all that's relevant.
  • syms x1 x2;
  • y1 = x1^2;
  • slope_y1 = diff(x1^2);
  • slope_y2 = -1/subs(slope_y1,2);
  • %y = mx+b
  • %y-mx = b
  • b = 4-slope_y2*2;
  • y2 = slope_y2*x2+b;
  • x_intercept_y2 = solve(y2,0);
  • area_y1 = int(y1,0,2);
  • area_y2 = int(y2,2,x_intercept_y2);
  • area = area_y1+area_y2
  • figure
  • hold on
  • x1 = 0:.01:2;
  • y1 = eval(vectorize(y1));
  • plot(x1,y1,'LineWidth',2,'color','b')
  • x2 = 2:.01:18;
  • y2 = eval(vectorize(y2));
  • plot(x2,y2,'LineWidth',2,'color','r')
  • x3 = (0:.01:18);
  • plot(x3,0,'LineWidth',2,'color','m')
  • plot([-2 20],0, 'k')
  • axis([-2 20 -1 5])
  • plot([-2 0],[0 0],'k')
  • plot([18 20],[0 0],'k')
  • plot([0 0],[-2 5],'k')
  • set(gca,'Xtick',[5 10 15])
Could someone please tell me where I went wrong?

답변 (2개)

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015년 3월 9일

0 개 추천

If you want to remove the ticks from both x axis and y axis , do this:
set(gca,'Xtick',[], 'Ytick', [])

댓글 수: 3

Haden Mattke
Haden Mattke 2015년 3월 9일
I want to ADD tick marks
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015년 3월 9일
편집: Giorgos Papakonstantinou 2015년 3월 9일
Sorry I understood the opposite. When I execute your code I see tick marks at exactly where you want them i.e. 5, 10, 15
Haden Mattke
Haden Mattke 2015년 3월 9일
Thanks for taking a look. I was intending to change gridlines, not tick marks. I just needed to use {grid on}

댓글을 달려면 로그인하십시오.

Star Strider
Star Strider 2015년 3월 9일

0 개 추천

See Axis Properties, specifically Tick Values and Labels. I don’t see where you might have turned your tick marks off, so I would comment-out various plotting lines until I found the guilty one. One possibility to get them back is to add 'XTickLabel' to your set call:
set(gca,'Xtick',[5 10 15], 'XTickLabel',[5 10 15])

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

제품

질문:

2015년 3월 9일

답변:

2015년 3월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by