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

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
greyman
Messages
2
Reaction score
0
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).
 
Physics news on Phys.org
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
 
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.