MATLAB: How to set log scale range

log scaleyticklabel

is it possible to set the range of matlab plot
set(gca,'XTick',(6:2:14),'XTickLabel',(6:2:14),'YTick',(1E-30:1E2:1E-22),...
'YTickLabel',(1E-30:1E2:1E-22));
However, it gives me wrong yticklabel, I want yticklabel like '1E-30', '1E-28', '1E-26', '1E-24', '1E-22'
what is the correct range (1E-30:1E2:1E-22) that i could use to define this?

Best Answer

yt = logspace(-30, -22, 5);
set(gca, 'XTick', 6:2:14, 'XTickLabel', 6:2:14, ...
'YTick', yt, 'YTickLabel', yt, ...
'XLim', [6, 14], 'YLim', [1e-30, 1e-22], ...
'YScale', 'log');
Use logspace to get the Y-ticks. Set the ranges accordingly and set Y-scaling to logarithmic.
By the way: You do not have to define the tick labels, if they are the same as the tick values.