I am trying to plot a graph and then I want to update the x axis labels like the following:
0 50 100 150 200 250 and so on up to 1000
I have tried the below. But I cannot seem to get it to display here apart of my data and plot for your information. Can someone please help. This is really confusing me now.
y= ones(1, 20) * 0.7038;
plot(y,'-.','LineWidth',2);
hold off
x=[0:50:1000];
set(gca,'XTick', x);

 채택된 답변

darova
darova 2020년 3월 23일

1 개 추천

Here they are

댓글 수: 3

EJ_92
EJ_92 2020년 3월 24일
편집: EJ_92 2020년 3월 24일
If I wanted to plot multiple lines on the same graph how would I do this? I have tried the below but this is given me an error
Vectors must be the same length.
x = [0:50:100];
y = ones(1, 20) * 0.7038;
z = ones(1, 20) * 0.5039;
plot(x(2:end),y,'-.','LineWidth',2);
hold on
plot(x(2:end),z,'-.','LineWidth',2);
hold off
set(gca,'XTick', x);
darova
darova 2020년 3월 24일
You forgot '0'
EJ_92
EJ_92 2020년 3월 24일
Ah sorry only realised this. Thanks its working now!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품

릴리스

R2019b

질문:

2020년 3월 23일

댓글:

2020년 3월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by