How do I read the last document from a directory

I´ll explain my question:
I have a directory in which new results are posted as new documents everyday and Matlab does a process with the newest to give a results file. How can I set an .m file to choose the newest file everytime?

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 13 de Mzo. de 2013
Editada: Azzi Abdelmalek el 13 de Mzo. de 2013
d=dir('*.mat'); % if you need mat files
dates={d.date};
files={d.files};
[~,idx]=sort(datenum(dates));
new_file=files{idx(end)}

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by