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

Click For Summary
SUMMARY

The discussion focuses on adjusting the spacing of values on the X-axis in MATLAB for a plot displaying powers of 2 from 1 to 1024. The user initially struggled with uneven spacing of these values but successfully resolved the issue by utilizing the semilogx function. This approach allowed for proper representation of the data while maintaining the correct graphical alignment. Additionally, the use of xtick and xticklabel properties was suggested as a method for customizing axis labels.

PREREQUISITES
  • Basic understanding of MATLAB syntax and functions
  • Familiarity with plotting functions in MATLAB
  • Knowledge of logarithmic scales in data visualization
  • Understanding of axis properties in MATLAB graphics
NEXT STEPS
  • Explore the loglog function for creating logarithmic plots
  • Research the semilogy function for plotting with a logarithmic Y-axis
  • Learn how to customize plot axes using axes properties
  • Investigate advanced MATLAB plotting techniques for better data visualization
USEFUL FOR

This discussion is beneficial for MATLAB users, data analysts, and engineers who require precise control over plot formatting and axis representation in their graphical data presentations.

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 ·
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K