MATLAB: Format axes Tick Labels in log scale

axisformatlabelslogtick

Dear all, an annoying issue when plotting on log scales, is apparently not being able to control the format of axis tick labels.
For example: given XTick = [0.1,1,10,30];
I want to manually set my own labels, e.g. XTickLabels = num2str(10^-1, 10^0, 10^1, 10^-1].
How can I format XTickLabels so that I display tick labels as powers of ten (i.e. base^{exponent} in latex interpreter)?
Right now MATLAB either omits the last label if XTickLabelModel is 'auto' or can display strings of the type '10^X' or can show only numbers as decimals (i.e. '0.1, 1, 10, 0.1').
Is there a way to control directly the format of axis tick labels, or I have to work it around using a text(-) object and switching XTickLabels off?
Thank you in advance for your help. Maurizio

Best Answer

XTickLabels = cellstr(num2str(round(log10(XTick(:))), '10^%d'));