How to change x and y labels limts

2 次查看(过去 30 天)
Hi,
I have a problem with my plot axes labels. I want to have my own range on x-axis and y-axis. On the y - 0:200 and the interval 20. On the x (time mm:ss) - 00:00 : 20:00 and the interval 2 minutes.
a=['00:00';
'00:42';
'00:49';
'00:56';
'02:00';
'02:24';
'02:52';
'03:23';
'04:22';
'05:52';
'06:41';
'08:40';
'09:18';
'10:27';
'11:01';
'11:14';
'11:31';
'11:49';
'12:04']
b=[27.6;
32.1;
37.9;
41.1;
68;
79.6;
89.7;
92.5;
93.4;
93.4;
93.7;
100.3;
109.8;
135.8;
151.1;
160.4;
167.5;
174.6;
179.7]
c=datenum(a, 'MM:SS');
plot(c,b,"-o");
xlabel("Czas [min:sec]")
ylabel("Temperatura [%%cC]")
hold on;
datetick('x','MM:SS')
  3 个评论
Damian Konaszewski
Damian Konaszewski 2020-3-15
Can you help me with the code? I don't know how to use duration.
dpb
dpb 2020-3-15
How did you learn to use datenum? Read the doc first and give it a go...much faster than waiting on us.

请先登录,再进行评论。

采纳的回答

Damian Konaszewski
Damian Konaszewski 2020-3-15
Anyone else can help me with my problem?
  2 个评论
Ameer Hamza
Ameer Hamza 2020-3-15
dpb told you a method. Have your tried that?
Damian Konaszewski
Damian Konaszewski 2020-3-15
Yes. When I put duration i got error. When I use xtick, the label didnt; fit to reality.

请先登录,再进行评论。

更多回答(2 个)

dpb
dpb 2020-3-15
编辑:dpb 2020-3-15
"When I put duration i got error. When I use xtick, the label didnt; fit to reality. "
Must not have tried very hard or read the doc at all... :(
d=duration(cellstr(a),'InputFormat','hh:mm','Format','hh:mm');
plot(d,b)
xlim([hours(0) hours(14)])
ylim([0 200])
xticks(hours(0:2:14))
grid on
produces:

Damian Konaszewski
Damian Konaszewski 2020-3-15
I want to get sth like this but in matlab. On the x-axis i want to get 0 2 4 6 8 10 12 14.

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by