How to load an Excel file that changes with the date?

1 visualización (últimos 30 días)
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.

Respuesta aceptada

meghannmarie
meghannmarie el 30 de Sept. de 2019
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 ']
  1 comentario
Sophia Collinson
Sophia Collinson el 1 de Oct. de 2019
Thank you so much! That's exactly what I needed, it all works perfectly now!

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by