Resize a MATLAB Shape

I have a number that displays 20,000 points on the x axis. So it marks the x axis from 0 ... 20 000. However, now I would like to scale it from 0 to 50. But when I try to do this in the plot window, it just shows me the first 50 points, instead of changing the scale. Is there any easy way to do this in MATLAB?

+3
source share
3 answers

You need to change the x values ​​on your chart or change the axis labels.

Here's how you draw using specific x values:

%# create some data
data = randn(20000,1);

%# create 20,000 corresponding x-values so that the last one is 50 - works for any number of data points
x = linspace(1,50,length(data));

%# plot
plot(x,data)

EDIT Doresoom conveniently showed how to change axis labels.

+4
source

Try using the axis property xticklabel.

set(gca,'XTickLabel',{'0';'10';'20';'30';'40';'50'}) , .

EDIT:

, . , , MATLAB . , , :

set(gca,'XTick',[0:4000:20000])
+2

, . x- .

, linspace(0, 50, 20000) x- plot, x 0 50, d , , , .

+1

Source: https://habr.com/ru/post/1737180/


All Articles