MATLAB: How to convert an array to corresponding weekdays

datetime

If I have an array z = [ 1 2 3 4 5 6 7], how can I convert it to corresponding weekdays like p = [ monday tuesday wednesday thursday friday saturday sunday]?

Best Answer

I am not certain what you want.
Try this:
z = [ 1 2 3 4 5 6 7];
p = { 'monday' 'tuesday' 'wednesday' 'thursday' 'friday' 'saturday' 'sunday' };
chooseDay = 4;
Out = p(z == chooseDay)
producing:
Out =
1×1 cell array
{'thursday'}
.