Input Dates from an excel sheet without getting a NaN

A
Hi there, I would like to input Column A and Plot it against Column F however I get the error message that values must be an integer.
M= readmatrixFilename
Date= M(:,0)
*error*
maxHeight = M(:,4)
Is there a way to inform matlab that M(:,0) is Date/Time data without it spitting out an error and therefore being able to plot the max wave height from 01/04/2021-31/03/2022
Apologies I asked something similar previously as can be seen above.
Thanks in advance

답변 (1개)

Voss
Voss 2022년 5월 2일
편집: Voss 2022년 5월 2일
M(:,0) would refer to the 0th column of M, but indexing in MATLAB starts at 1. There is no 0th column, so that's why you get that error message (which specifies positive integer). It's not because of Date/Time data. Try:
Date = M(:,1)
and see what that gives you.
Related:
maxHeight = M(:,5)

댓글 수: 2

Ah that helps, although when I then plot it,
plot (M(:,1),M(:,5)
My X axis which should be date is a numeric value of 4.425x10^4, how would I format that to say 01 Apr etc
I would try
Date = datetime(M(:,1))
and use that to plot instead of M(:,1). But the value you report (4.425x10^4) doesn't seem like it would correspond to any date near 31/03/2022, so I don't know for sure.
Maybe upload the file (using the paperclip button) if you continue to have trouble.

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

카테고리

도움말 센터File Exchange에서 Time Series Objects에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 5월 2일

댓글:

2022년 5월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by