Rescale an axis in other steps without creating vector
이전 댓글 표시
Hello,
I have the following problem: I have for example 1000 measurement points but in 0.02 second steps. In the plot I want to have not a scale from 0 to 1000 but from 0 to 20 (=1000*0.02). As I don't know the length of my data points, I cannot create a vector in 0.02 steps for the x-axis because then Matlab returns that the vectors must be the same lengths.
Is there a possibility, just to divide the x-axis by 50?
Thanks, Leo
답변 (4개)
You can control your x-axis by plotting your data against your time as follows:
y = rand(1, 1000); % your data
x = linspace(0, 0.02, numel(y)); % your time series
plot(x, y) % your plot of data against time series
or you can use 'xlim' for this purpose. see
doc xlim
for more information
Try this:
y = rand(1, 1000); % your data
x = linspace(0, 20, numel(y)); % your time series
plot(x, y) % your plot of data against time series
It will plot 1000 points within range of 0 to 20
Leonard
2013년 12월 3일
댓글 수: 3
sixwwwwww
2013년 12월 3일
whats the difference in your code and solution I provided? I am also generating the same values of x = 0.02 0.04 ...
you can run my code and then you can see workspace varaiable x for confirmation. Also I appreciate you in a way that you found it yourself as well and it is a better way of learning. Good luck!
Leonard
2013년 12월 3일
sixwwwwww
2013년 12월 3일
In my case 20 is not fix. in the following line of code you can just replace 20 by any value then it will also work
x = linspace(0, 20, numel(y));
Good luck!
카테고리
도움말 센터 및 File Exchange에서 Time Series Events에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!