How to create a function, that outputs Weekdays on given date?
3 次查看(过去 30 天)
显示 更早的评论
hello everyone,
basically i have to create my own function, which gives me the weekday when i give date. for exp in this format :
input : 26,06,2021
output : Date = 26,06,2021
Day = Saturday
I am trying to write it, but i am not getting any further, i would really appreciate it, if anyone can help me.
0 个评论
回答(1 个)
Cris LaPierre
2021-11-1
D = datetime(2021,06,26);
out = day(D,'name')
4 个评论
Dianela Jimenez Ramirez
2022-3-12
Hi Cris, your comment has been very helpful! I´m wondering if there is a way to show only day and hide the phrase in the output out = 1×1 cell array. Thank you!
Cris LaPierre
2022-3-12
Use the function disp
D = datetime(2021,06,26);
out = day(D,'name');
disp(out{1})
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!