Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plot - Radian Scale (MATLAB)

  1. Oct 3, 2009 #1

    danago

    User Avatar
    Gold Member

    I want to create a plot, but want the horizontal axis to have increments as multiples of pi eg. {0, pi/2, pi, 3pi/2, ... }

    Is this at all possible in matlab?
     
  2. jcsd
  3. Oct 3, 2009 #2

    jamesrc

    User Avatar
    Science Advisor
    Gold Member

    Yes - you can set where the tick marks are on an axis:

    This will control where the ticks go (use whatever range you want):
    set(gca,'XTick',0:pi/2:3*pi/2)

    (Note that gca returns the handle for the current set of axes)

    This will control the labels for the ticks:
    set(gca,'XTickLabel',{'0','pi/2','pi','3pi/2'})


    So you can attach text labels to all of your tick marks - make sure that you have the correct number of labels - I think if you have more tick marks than labels, MATLAB will just cycle back through your list of labels for the extra tick marks. Also, I know that MATLAB supports some tex and latex formatting so that you could display [tex] \pi [/tex] instead of pi, but I'm not sure if that is supported for tick labels (and if it is I'd have to play around with it to figure out how that works).
     
  4. Oct 3, 2009 #3

    danago

    User Avatar
    Gold Member

    Thanks very much, exactly what i was after :smile:
     
  5. Oct 3, 2009 #4
    Unfortunately, matlab cant display tex characters in tick labels.

     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Plot - Radian Scale (MATLAB)
  1. Plotting in matlab (Replies: 0)

  2. MATLAB plots (Replies: 1)

  3. Matlab Plot (Replies: 2)

  4. Plotting in MATLAB (Replies: 8)

  5. Plotting with MATLAB (Replies: 1)

Loading...