How to load an Excel file that changes with the date?
3 次查看(过去 30 天)
显示 更早的评论
I've created a script that loads and creates a graph from the reliability of the computers within a department. The excel file that contains the data is created new each morning with the date that it is loading for. The date that comes up is in the format such as 30_9_2019, I have requested for it to be changed to a dd_mm_yyyy format, as when trying the
>> date = today('datetime')
date =
datetime
30-Sep-2019
>> formatOut = 'dd_mm_yyyy'
formatOut =
'dd_mm_yyyy'
>> datestr(now,formatOut)
ans =
'30_09_2019'
The whole title for the file is currently d_m_yyyy_04_01_AMReliability.csv with the day and month varying between dd and mm depending on the date, of course.
One issue I find is that when you trt and get Matlab to run from dd_m_yyyy it comes up with a letter for the month.
Is there any way I can get matlab to find the new name automatically as otherwise the date has to be changed and run manually every morning.
0 个评论
采纳的回答
meghannmarie
2019-9-30
You could just convert numbers to string and piece it together like this:
date = datetime('now');
[y,m,d] = ymd(date);
filename = [num2str(d) '_' num2str(m) '_' num2str(y) '_04_01_AMReliability.csv ']
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!