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

How to change the width between values on an axis in matlab?

  1. Nov 2, 2010 #1
    Hello! I'm very new to matlab and came across a problem: I need on the X axis values from 1 to 1024, only the powers of 2. I managed to get matlab to show only these values but as they would be when all the values are shown (1 and 2 are one ever the other and 512 and 1024 are far away one from the other) hope you understand :) So I want all of them to have even spacing between them and obviously be in concordance with the graphic (not to be only labels).
     
  2. jcsd
  3. Nov 4, 2010 #2

    MATLABdude

    User Avatar
    Science Advisor

    Welcome to PhysicsForums!

    Perhaps I'm not understanding the question, but are you asking about making a log (or semilog) plot?
    http://www.mathworks.com/help/techdoc/ref/loglog.html
    http://www.mathworks.com/help/techdoc/ref/semilogx.html
    http://www.mathworks.com/help/techdoc/ref/semilogy.html

    The other thing you could do is plot the log(x), rather than x itself, and change the axis label accordingly.

    If your plot is okay, and you're trying to change which numbers are present (or, relabel them) you can make use of the xtick or xticklabel properties:
    http://www.mathworks.com/help/techdoc/ref/axes_props.html#XTick
     
  4. Nov 5, 2010 #3
    Thank you for the answer, I solved it with semilogx. I had the numbers I wanted present but the space between them wasn't right, they were one ever the other at the beginning.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook