The ability to specify the precision of the tick labels on an axis is not available in MATLAB 7.3 (R2006b).
To work around this issue, you can retrieve the ticks, convert them to strings with a specified precision, and set the labels to the new tick labels. The following example code can be executed at the MATLAB command prompt, to illustrate this work around:
% Create an example plot.
plot(1:10);
% Query xTick numerical values.
xTick = get(gca,'xTick');
% Create strings out of xTick numerical values with a prescribed precision.
% The format string '%a.bf' means to present the values within a field that
% is wide enough to fit 'a' digits with 'b' digits after the decimal point
% in the format of a 'f'loating point number.
xTickLabel = arrayfun( @(x) sprintf('%3.2f',x), xTick, 'uniformoutput', false);
% Use xTickLabel on the plot.
set(gca, 'xTickLabel', xTickLabel);
Note that once the tick labels have been set, they are in manual mode. The tick labels will not update automatically with the resizing of the figure window or zooming in and out of the window.
Ref: https://www.mathworks.com/support/solutions/en/data/1-3P8CU0/index.html
1
Ther is an active group of Matlab programmers at StackOverflow. Have a look at the Matlab tags and consider posting there.
– ephsmith – 2012-07-21T15:09:03.487@ephsmith thanks, next question will go to StackOverflow :) – javapowered – 2012-07-21T16:55:06.570