Why is the maximum length of a datetime array 142?
6 views (last 30 days)
Show older comments
Hello,
I am trying to initialize a vector of datetime arrays and I can't go beyond a length of 142. Why is that? Is there a workaround?
Here's my code:
datetime_array = NaT(1,length(myTimeStamps));
for i=1:length(datetime_array)
datetime_array(i,:) = datetime(myTimeStamps(i,:);
end
Error: Index in position 1 exceeds array bounds (must not exceed 142).
Thank you,
Lindsey
3 Comments
Adam Danz
on 22 Jul 2019
Datetime array can be much longer than 142. This one below is 10,000 timestamps long.
datetime(1950,1:10000,1)
What is stored in myTimeStamps? Could your provide an example? Perhaps one of them is empty.
Accepted Answer
Star Strider
on 22 Jul 2019
The ‘142’ value is most likely the row size of the datetime array in your code, and you are apparently addressing it beyond that limit.
4 Comments
Guillaume
on 23 Jul 2019
The morale of the story is never use length. If you mean the length of a vector, use numel, and if you're operating on a matrix, use size with an explicit dimension.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!