How to simply add the date to a file name when saving a file.

9 ビュー (過去 30 日間)
Matthew Munster
Matthew Munster 2013 年 12 月 5 日
コメント済み: Matthew Munster 2013 年 12 月 5 日
Hello, I'm currently working on a program for a final in my Engineering Programming class. The guidelines are as followed:
1.) Generate a function that accept a function and calculates the values of that function from x = a to x = b in step size h
2.) Save the calculated values in a file that is date-stored and "other identities". Examples:
--project 2 dec04mattmunster.dat --proj12042013mmunster.dat
3.) Compare your data to a set of data I will give you in file format
4.) Plot 2 graphs: -1st graph = your data in a subpot and my data in another subplot -2nd graph = your data/my data overlaid
Currently I have the main function in Part 1 completed however I cannot figure out how to created a "date-stored" file name like the examples above in Part 2. Currently I have this:
>>function FinalProject = FinalProject(f,a,b,h)
>>FinalProject = f(a:h:b);
>>dlmwrite(mmunster,FinalProject,',')
>>end
dlmwrite prints out the date perfectly well but I need more than that in the file name like the examples above. Help?
(I don't need assistance with the other parts....yet)
Thank you

採用された回答

ES
ES 2013 年 12 月 5 日
get the datestring above, make the filename as per your need with the datestring.
eg:
FileName=['proj',datestr(now, 'dd-mmm-yyyy'),'mmunster.dat'];
use this FileName in your dlmwrite.
  1 件のコメント
Matthew Munster
Matthew Munster 2013 年 12 月 5 日
Fantastic, works great! Thank You!

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 12 月 5 日
Example:
datestr(now, 'dd-mmm-yyyy')
  1 件のコメント
Matthew Munster
Matthew Munster 2013 年 12 月 5 日
That just prints the date and time, I need that in addition to a file name
ex: project dd-mm-yyyy HH:MM:SS

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStandard File Formats についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by