How do I extract current executing file name to be inserted into a plot?

1 回表示 (過去 30 日間)
Don Edberg
Don Edberg 2011 年 9 月 7 日
Hello,
I am executing a bunch of different m-files and need to distinguish the plots each outputs, by putting the associated file name that generated the plot into the plot.
1. When a m-file executes, is there a way to get the current m-file's name and include it in a plot?
2. Is there a way to similarly insert the date of execution (like a "timestamp")?
3. May I command MATLAB to display this information vertically, on the outside of the plot area, at the extreme right? For instance the plot would say "filename = sample.m, 7 SEP 2011" on its right.
I have looked in the documentation and did not find this information, although I admit to being a MATLAB novice. I would appreciate any help that can be provided.
Thanks, Don

採用された回答

Paulo Silva
Paulo Silva 2011 年 9 月 7 日
MyMsg=[mfilename ',' date]'
spy
uicontrol('style','text','string',MyMsg,'Position',[520 10 20 400])
  1 件のコメント
Don Edberg
Don Edberg 2011 年 9 月 8 日
Awesome! thanks to both of you. I really appreciate it! How does that spy figure get into my machine? that's amazing. -- Don

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 9 月 7 日
1. Please see mfilename()
2. datestr(now)
3. text() the string in to place, with 'HorizontalAlignment', 'right' and with 'Rotation' of -90, and with 'Units', 'normalized'. The upper right corner would be position 1, 1 in normalized units.
You might want to consider instead using title() or ylabel(), or setting the 'Name' property of the figure
  1 件のコメント
Don Edberg
Don Edberg 2011 年 9 月 8 日
Awesome! thanks to both of you. I really appreciate it! -- Don

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

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by