How to change x and y labels limts

3 visualizaciones (últimos 30 días)
Damian Konaszewski
Damian Konaszewski el 15 de Mzo. de 2020
Editada: dpb el 15 de Mzo. de 2020
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 comentarios
Damian Konaszewski
Damian Konaszewski el 15 de Mzo. de 2020
Can you help me with the code? I don't know how to use duration.
dpb
dpb el 15 de Mzo. de 2020
How did you learn to use datenum? Read the doc first and give it a go...much faster than waiting on us.

Iniciar sesión para comentar.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (2)

dpb
dpb el 15 de Mzo. de 2020
Editada: dpb el 15 de Mzo. de 2020
"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 el 15 de Mzo. de 2020
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.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by