Input Dates from an excel sheet without getting a NaN
이전 댓글 표시

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개)
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
Alfred Cox
2022년 5월 2일
Voss
2022년 5월 2일
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!