datestr generating different string

2 次查看(过去 30 天)
I have an array with days, months and years. This is my string
[myd '/' mym '/' myy]
ans =
20/01/2014
But datestr generates this
datestr([myd '/' mym '/' myy])
ans =
06-Jul-0025
Any clue?
Thanks

采纳的回答

Chad Greene
Chad Greene 2021-5-1
How about
myy = 2014;
mym = 1;
myd = 20;
datestr(datenum(myy,mym,myd),'dd/mm/yyyy')
ans = '20/01/2014'
  3 个评论
Chad Greene
Chad Greene 2021-5-1
How's this?
datestr(datenum(string([myd '/' mym '/' myy]),'dd/mm/yyyy'))
Simon Lind
Simon Lind 2021-5-1
I just removed the 'string' and now it works
datestr(datenum(([myd '/' mym '/' myy]),'dd/mm/yyyy'))
thank you very much!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operators and Elementary Operations 的更多信息

标签

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by