MATLAB: Floating Number without “e”

decimalfloating numberformatMATLAB

Hello everyone!
I'm a begginer in Matlab struggling to plot a graph. I'm having a hard difficult with my decimal numbers, because I have a very small one. My program is returning like "2.917974892076614e-04" and I didn't want this notation. I need the normal number, even if it is rounded – no problem!
Well, can I round the number to the maximum value acceptable by the var type? Or can I stop my program from writing like this and make it return the original number?

Best Answer

If you are using R2015b or later, do not bother trying to work with format or vpa() for this purpose. Instead, use
ax = gca;
ax.XRuler.TickLabelFormat = '%.5f';
or the same with YRuler .
R2015a had a similar facility but the name XRuler and YRuler were different in that one release.
For earlier releases, set the axis XTickLabel or YTickLabel properties as appropriate. For example,
xt = get(gca, 'XTick');
xlab = cellstr( num2str(xt(:), '%.5f') );
set(gca, 'XTickLabel', xlab)
When you work with XTickLabel or YTickLabel then if you zoom or pan then the labels are not automatically recreated in appropriate format to match new appropriate new ticks. When you work with the newer TickLabelFormat, then any new tick brought into view by zoom or pan will be automatically formatted properly.