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?

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 13 日
編集済み: Azzi Abdelmalek 2013 年 3 月 13 日

0 投票

d=dir('*.mat'); % if you need mat files
dates={d.date};
files={d.files};
[~,idx]=sort(datenum(dates));
new_file=files{idx(end)}

その他の回答 (1 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by