How to change x and y labels limts

2 ビュー (過去 30 日間)
Damian Konaszewski
Damian Konaszewski 2020 年 3 月 15 日
編集済み: dpb 2020 年 3 月 15 日
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 Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by