month number to month name function

60 次查看(过去 30 天)
mmmm
mmmm 2020-4-23
编辑: Rik 2020-4-23
Create a Matlab function
  4 个评论
madhan ravi
madhan ravi 2020-4-23
编辑:Rik 2020-4-23
[expletive] why would you do that? So annoying when people do this. So when you ask something online isn’t that obvious that it’ll visible for everyone?? Come on!!
Ameer Hamza
Ameer Hamza 2020-4-23
Name of Original OP: miika k
I am adding this to discourage such spamming behavior.

请先登录,再进行评论。

回答(2 个)

Johannes Hougaard
Johannes Hougaard 2020-4-23
This snippet should do it using existing functions.
month_number = 11;
month_name = datestr(datetime(1,month_number,1),'mmmm');
If you want it as a function just add a function header
function month_name = month_number2name(month_number)
month_name = datestr(datetime(1,month_number,1),'mmmm');

Ameer Hamza
Ameer Hamza 2020-4-23
编辑:Ameer Hamza 2020-4-23
This is one of the option
name = monthName(12);
function name = monthName(num)
name = month(datetime(1,num,1), 'name');
name = name{1};
end
Result:
name =
'December'

类别

Help CenterFile Exchange 中查找有关 String 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by