Hello,
I'm just trying to specify an input format for datetime(). Even running exemple code i get an error:
DateStrings = {'2014-05-26';'2014-08-03'};
t = datetime(DateStrings,'InputFormat','yyyy-MM-dd')
I get the error:
"Array formation and parentheses-style indexing with objects of class 'timerange' is not allowed. Use objects of class 'timerange' only as scalars or use a cell array."
My format case would be for a string as: '20050101_0010'
for which format would be: 'yyyyMMdd_HHmm'. I get the same error.
Does anyone know what's wrong?
Thanks in advance.

댓글 수: 1

Pol Cardona Rubio
Pol Cardona Rubio 2022년 4월 5일
편집: Pol Cardona Rubio 2022년 4월 5일
Just closing and openning matlab again solved it. So strange.

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

 채택된 답변

Jan
Jan 2022년 4월 5일
편집: Jan 2022년 4월 5일

1 개 추천

I guess, that you have defined "datetime" as a variable by accident.
datetime = timerange('12/18/2015 08:00:00', '12/18/2015 12:00:00');
S = {'2014-05-26'; '2014-08-03'};
t = datetime(S, 'InputFormat', 'yyyy-MM-dd')
Array formation and parentheses-style indexing with objects of class 'timerange' is not allowed. Use objects of class 'timerange' only as scalars or use a cell array.
Restarting Matlab cleared the variable called datetime implicitly.
You can check this in the future, if a command behaves strangely:
whos
which datetime -all

추가 답변 (0개)

카테고리

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

제품

릴리스

R2021b

태그

질문:

2022년 4월 5일

댓글:

2022년 4월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by