如何增加matlab Graph中的点数?

How to increase number of points in matlab Graph?

我有两个数组 xy。数组 x 包含值 10,20,30,40,....1000。数组 y 包含一些介于 0 到 1 之间的随机值。我在 Matlab 中绘制了图形,然后在 x 轴上它仅指向 100、200、300 ... 1000。所以图中的分析似乎不如预期。如果 x 轴包含差异较小的点间隔(此处为 100),则结果可能会很完美。怎么做?

Matlab 以足够清晰易读的间距向您显示 x 刻度。对于早期版本,您可以使用 xticks (and the same for yticks), if you have Matlab 2016b or later, and with set 命令根据需要设置 X 轴刻度的间距。这是一个例子:

x = 10:1000;
y = rand(1,size(x,2));
plot(x,y,'o')
set(gca,'XTick',50:50:1000) % <- set the places where X axis have ticks
% xticks(50:50:1000) % in version 2016b or later

上面例子的结果: