MATLAB: Formatting axes for a plot

plotting

Hello,
Why whenever I do this to format the x-axis to be between 0-6 and then type (x10^4) it does not show the x-ticks on the x-axis:
xVals = 0:.6:6;
set(gca,'xtick',xVals);
expVal = 4; %exponent you want
set(gca,'XTickLabel',sprintf('%2.1f|',xVals));%10^expVal));
pos = get(gca,'Position');
offset = 0.00; %how far to the right you want the exponent
annotation('textbox',[pos(1)+ pos(3)+offset, pos(2), 0.2, 0.2],...
'String',['$\times 10^' num2str(expVal) '$'],...
'Interpreter','latex',...
'VerticalAlignment','bottom',...
'EdgeColor','none')

Best Answer

If all you want to do is to add the annotation in your plot, you don't need to add the 'XTicks'.
You could just add this section to your original code:
pos = get(gca,'Position');
offset = 0.00; %how far to the right you want the exponent
annotation('textbox',[pos(1)+ pos(3)+offset, pos(2), 0.2, 0.2],...
'String',['$\times 10^' num2str(expVal) '$'],...
'Interpreter','latex',...
'VerticalAlignment','bottom',...
'EdgeColor','none')