Matlab Coder error : converting datetime Format error
1 view (last 30 days)
Show older comments
I have a problem about Matlab Coder... Actually, The code is correctly run in Matlab, but I want to use Matlab coder. Coder makes error, when I want to change datetime Format. For example, variable DateTime is type of datetime, 2017-05-01 00:00, 2017-05-01 00:15, ...... 2017-09-30 23:45 and I want to change it only year and date like, 20170501, 20170501, ...... , 20170930. That's why I make the code in matlab, d1 = datetime(DateTime, 'Format', 'uuuuMMdd');
DateTime = table2array(datatable(1:row/4,1)); % 2017-05-01 00:00, 2017-05-01 00:15, ...... 2017-09-30 23:45 d1 = datetime(DateTime, 'Format', 'uuuuMMdd'); % 20170501, 20170501, ...... , 20170930
In Matlab, it works correctly. But Matlab Coder can't call the function. I want to know how I can solve this problem...TT
0 Comments
Accepted Answer
VBBV
on 12 Dec 2022
Use the dateType argument for the datetime function
d1 = datetime(DateTime, 'dateType', 'yyyymmdd'); % use the dateType argument
instead of
d1 = datetime(DateTime, 'Format', 'uuuuMMdd'); % 20170501, 20170501, ...... , 20170930
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!