本文介绍了Matlab带有某些标签的刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下部分:

set(gca,'ylim',[0 0.3],'ytick',0:0.05:0.3);
set(gca,'xlim',[0 1],'xtick',0:0.05:1);

滴答声必须保持原样,因为当我启用网格时,滴答声会给我我想要的网格分辨率.我还想要更改x和y的标签.

Ticks must remain as they are since when I enable the grid, ticks give me the grid resolution I want. What I also want is that I want to change the labels of x and y.

我希望MATLAB显示所有刻度,但仅显示以下刻度标记:

I want MATLAB to show all ticks but only show the following ticks' label:

0, 0.2, 0.4, 0.8, 1.0表示x

0, 0.1, 0.2, 0.3表示y

有没有办法做到这一点?

Is there a way to do this?

推荐答案

您可以使用字符串的单元格数组为刻度线分配标签,其中每个字符串都对应一个刻度线.对于不需要标签的刻度,请使用空字符串:

You can assign labels to ticks using a cell array of strings, where each string corresponds to a tick. For ticks at which you don't want any label, use the empty string:

set(gca,'xticklabel',{'0','','','','0.2','','','','0.4','','','','0.6','','','','0.8','','','','1'})
set(gca,'yticklabel',{'0','','0.1','','0.2','','0.3'})

这篇关于Matlab带有某些标签的刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 22:38