How do I get the file date and time
55 ビュー (過去 30 日間)
古いコメントを表示
Hello folks,
in my Simulink model I want to create a block which will read from a file from time to time. The file will not be updated every time the block runs, so in order to save the performance for fopen'ing the file I would just like to check on the file date and time.
Is there any handy Matlab function which will return the file's date and time as a number (e.g. double, 32 bit int etc.)
This is for Matlab / Simulink R2012a, running on WinXP.
Thanks for any hints
Norbert
0 件のコメント
採用された回答
TAB
2012 年 3 月 23 日
FileInfo = dir('YourFileWithExtention');
TimeStamp = FileInfo.date;
By the way, in which block of simulink you are using fopen.
[Edited 26 Mar, 2012]
% Get individual components of date & time in 1 Sec resolution
FileInfo = dir('YourFileWithExtention');
[Y, M, D, H, MN, S] = datevec(FileInfo.datenum);
Declare datevec as extrinsic before using.
4 件のコメント
TAB
2012 年 3 月 26 日
Above functions always returns time with 1 sec resolution.
FileInfo.date will resurn the whole value as string.
If you are using embedded matlab function block, you can also evaluate the invidual values of Year, date, month.....etc.
Please see my edited answer.
その他の回答 (2 件)
Tony Jiang
2016 年 6 月 2 日
編集済み: Tony Jiang
2016 年 6 月 2 日
datestr(FileInfo.date,29) will report the date only without the time info. you can play with the different formatting in datestr though..
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!