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

In summary, the conversation discusses a problem with displaying values on the X axis in MATLAB. The goal is to have evenly spaced powers of 2 from 1 to 1024, while still maintaining the correct graphic. Suggestions for solving this issue include using log or semilog plots, or adjusting the xtick or xticklabel properties. The issue is eventually resolved using semilogx.
  • #1
greyman
2
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
  • #2
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
 
  • #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.
 

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

1. How do I change the width between values on an axis in Matlab?

To change the width between values on an axis in Matlab, you can use the xlim function. This function allows you to set the minimum and maximum values for the x-axis, which will automatically adjust the width between values. You can also use the xticks function to manually specify the positions of the tick marks on the x-axis.

2. Can I change the width between values on both the x-axis and y-axis simultaneously?

Yes, you can change the width between values on both the x-axis and y-axis simultaneously by using the xlim and ylim functions. These functions allow you to set the minimum and maximum values for both axes, as well as specify the positions of the tick marks.

3. How do I adjust the width between values on a logarithmic scale?

To adjust the width between values on a logarithmic scale, you can use the logspace function. This function allows you to specify the minimum and maximum values for the axis, as well as the number of points you want to appear between these values. This will automatically adjust the width between values on the logarithmic scale.

4. Is it possible to change the width between values on a specific axis?

Yes, it is possible to change the width between values on a specific axis in Matlab. You can use the xlim and ylim functions to specify the axis you want to adjust, and then set the minimum and maximum values and tick mark positions accordingly.

5. How can I change the spacing between tick marks on an axis?

To change the spacing between tick marks on an axis, you can use the xticks and yticks functions. These functions allow you to manually specify the positions of the tick marks on the axis, allowing you to adjust the spacing between them as desired.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
764
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
750
Back
Top