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

AI Thread Summary
The discussion centers around a MATLAB user seeking to plot values on the X-axis that represent only the powers of 2, specifically from 1 to 1024, while maintaining even spacing between these values. The initial concern was that the powers of 2 were displayed too closely together or too far apart on the graph. Suggestions included using log or semilog plots to achieve the desired spacing, with references to MATLAB documentation for loglog, semilogx, and semilogy functions. The user ultimately resolved the issue by utilizing the semilogx function, which allowed for the correct display of the desired numbers with appropriate spacing.
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.
 

Similar threads

Replies
10
Views
3K
Replies
4
Views
1K
Replies
1
Views
2K
Replies
2
Views
1K
Replies
1
Views
2K
Replies
12
Views
4K
Back
Top