Scale plot of datetime x-axis

조회 수: 10 (최근 30일)
JayPr1313
JayPr1313 2020년 5월 14일
댓글: Ameer Hamza 2020년 5월 17일
Hello MatLab-Friends,
I want to scale a graph in order to plot just a section of it and not the whole data with the whole time. The graph has a number on the y-axis (which is easy to scale with the ylim-funtion) and datetime on the x-axis(which is the problem). The format of the datetime is dd.MM.yyyy HH:mm:ss,SSSSSS (for example: 29.04.2020 16:39:57,593613). I tried to use the xlim-fuction in different ways but couldn t find the right solution...
Here is a part of my code.
subplot(4,1,4);plot(Time_FM4,DruckFM4_P6);
xlabel('Zeit'); ylabel('Druck in Pa');legend('Messpunkt 6','location','southwest'); ylim([100 200]); xlim(datetime([29.04.2020 16:48:43,452692 29.04.2020 16:48:51,053126]));
xl=xlim
grid on
Thank you in advance!
Cheers
Jason

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 14일
datetime accepts a char array or a string. Write it like this
xlim(datetime(["29.04.2020 16:48:43,452692" "29.04.2020 16:48:43,452692"], 'InputFormat', 'dd.MM.yyyy HH:mm:ss,SSSSSS'))

추가 답변 (1개)

JayPr1313
JayPr1313 2020년 5월 17일
편집: JayPr1313 2020년 5월 17일
Thanks a lot Ameer it works great!
  댓글 수: 1
Ameer Hamza
Ameer Hamza 2020년 5월 17일
I am glad to be of help.

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

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by