Select a different base for a logarithmic plot in matlab -


i want have x-axis logarithmic base 2: 2^10 2^25 , @ each step exponent should increase one, while y-axis should linear.

how possible? figured out

set(gca,'xscale','log') 

but u can't set base.

consider example:

%# random data x = 2.^(0:10); y = rand(size(x));  plot(log2(x), y)                               %# plot on log2 x-scale set(gca, 'xticklabel',[])                      %# suppress current x-labels  xt = get(gca, 'xtick'); yl = get(gca, 'ylim'); str = cellstr( num2str(xt(:),'2^{%d}') );      %# format x-ticks 2^{xx} htxt = text(xt, yl(ones(size(xt))), str, ...   %# create text @ same locations     'interpreter','tex', ...                   %# specify tex interpreter     'verticalalignment','top', ...             %# v-align underneath     'horizontalalignment','center');           %# h-aligh centered 

alt text


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -