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

The # of signinficant digits in Matlab plot

  1. May 12, 2010 #1
    When I plot a function using MATLAB where the y-axis, for example, has values of : 1.8, 1.9, 2.0 , 2.1

    Matlab ignores the number of siginficant digits when printing the value of 2.0, so it prints out:

    1.8, 1.9, 2, 2.1

    It there a way to change this?

    Thank you in advance
     
  2. jcsd
  3. May 13, 2010 #2
    XTickLabel is a property of the graph which you can set, and you can set it as strings so MATLAB doesn't automatically round the numbers off.

    For example:

    Code (Text):

    >> set(gca,'XTickLabel',{'1.8';'1.9';'2.0';'2.1';'2.2'})
     
    The hassle is you have to type all the other ones as well, but it works. There might be a shortcut.
     
  4. May 13, 2010 #3
    Thank you very much! It worked!
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook