how do I change numbers to dates?
2 views (last 30 days)
Show older comments
Liberty Crawford
on 14 Oct 2021
Commented: Image Analyst
on 14 Oct 2021
So I'm pretty knew to matlab and I'm trying to take a column of data that is filled with numbers between 1-12 and change them into their respective months. Is that even posible and if so, how? Thank you! :)
0 Comments
Accepted Answer
Image Analyst
on 14 Oct 2021
Use the datetime() function and the month() function:
monthNumberArray = 1:12; % Vector of whatever months you want.
t = datetime(2021, monthNumberArray, 1)
m = month(t, 'name')
monthNumberArray = randi([1 12], 1, 5); % Vector of whatever months you want.
t = datetime(2021, monthNumberArray, 1)
m = month(t, 'name')
2 Comments
Image Analyst
on 14 Oct 2021
If the Answer works, you can click the "Accept this answer" link to award the answerer "reputation points." Thanks in advance.
More Answers (0)
See Also
Categories
Find more on Dates and Time 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!