简体   繁体   English

如何绘制两个x轴的功率?

[英]How can I plot power of two x-axis?

How can I plot a x-axis that just have numbers like 1,2,4,8,16,... (power of two)? 如何绘制一个只有1,2,4,8,16,......(2的幂)的数字的x轴? I want this axis just have these numbers and no other number. 我希望这个轴只有这些数字而没有其他数字。 I am a newbee in matlab 我是matlab的新手

You can play with the axis properties of a plot, especially xtick and xticklabels . 您可以使用绘图的轴属性 ,尤其是xtickxticklabels The first one lets you set your own location of tick-marks, the second lets you set arbitrary labels for those ticks. 第一个允许您设置自己的刻度标记位置,第二个允许您为这些刻度设置任意标签。 Example: 例:

x = logspace(0, log10(64), 100);
plot(x, log2(x)) % plot something
set(gca, 'xtick', (2.^(0:6))) % set ticks at 1,2,4,8,...
set(gca, 'xscale', 'log') % scale x-axis logarithmic

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM