Somehow, copying the loop from this editor and pasting it into matlab fixed the issue. I am unsure the cause.
datetime reading out NaT for all rows of structure except last in loop
조회 수: 3 (최근 30일)
이전 댓글 표시
I am trying to get durations of a reoccurring event in a timetable by taking the datestring of a file and removing a duration from the timetable. When I try to convert the datestrings in a structure, all but the last row is output as NaT. I've tried setting the input format as well. For some reason I got it to work once but when I added it to my function this problem started happening.
I've pasted the for loop below and in this editor it seems to be working but I'm confused as to why it doesn't work in my function.
load sweep_data.mat
for n = 1:length(sweep_struct)
sweep_datetime(n,1) = datetime(sweep_struct(n).date);
end
댓글 수: 3
Stephen23
2022년 9월 12일
Avoiding the loop is easy:
S = load('sweep_data.mat');
D = datetime({S.sweep_struct.date}).'
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!