Hi,
I'm plotting a 1470x28 double and I need to rescale the x axis. Right now, the x axis shows data from 0 to 1470, but I need to convert the units of the x axis so that they show the same data, but it says 0 to 2940 instead. Basically i just want the 1500 on the bottom right to become 3000 and I want the data to still extend to the 3000 tick. I attached a pic of what I currently have. Thanks.

 채택된 답변

Les Beckham
Les Beckham 2022년 5월 3일
편집: Les Beckham 2022년 5월 3일

0 개 추천

Since you didn't show the code you used to generate the plot or include the data, I'll have to guess what the problem might be.
data = rand(28,1470); % made up data
for i = 1:28
data(i,:) = data(i,:) + i; % offset the data so it won't be on top of each other
end
plot(data') % maybe you were plotting without an x vector?
t = linspace(0, 1470*2, 1470); % create a vector specifying the data to use for the x axis
figure
plot(t, data) % plot with new x data
Note the new range on the x axis.

추가 답변 (1개)

Voss
Voss 2022년 5월 3일

0 개 추천

Maybe this example will show you how you can do that.
First, I'll create a random matrix the same size as yours:
y = rand(1470,28);
And plot it like you are doing now (maybe):
subplot(3,1,1)
plot(y)
title('plot(y)')
That plots y against the sample numbers 1:1470.
Another way to do that is to explicitly use those numbers as x (the first argument) in plot:
subplot(3,1,2)
plot(1:1470,y) % same as first plot
title('plot(x,y)')
If you do it that way, then you can make x whatever you want (in this case, multiplying by 2):
subplot(3,1,3)
plot(2*(1:1470),y) % doubling x
title('plot(2*x,y)')

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2022년 5월 3일

편집:

2022년 5월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by