How to retrievre the code that generates a figure?

Hello everyone,
I am not actually stuck by any issues but I was just wondering if there was a way to get from a figure generated by matlab, the code responsible for its generation? Like if the code 'test.m' generates the figures test1.png, test2.png, is there a way to know that it is the 'test.m' code that generates these figures just from the figures?
During my PhD I created lots of Matlab routines which created a lot of figures. Now that I am trying to classify routines and figures, I feel that this kind of information would be valuable. This could be included in the properties of the figure, and easily retrieved with a single right click on the figure. Maybe this is already possible but I didn't find any similar topics here.
Thanks you,
Johan

 Accepted Answer

Unfortunately, no, information on which file was used to create a figure is not captured. Perhaps you could use Date Created and compare that to your code files?

3 Comments

Thank you for you answer.
The Date of creation of a figure might not be relevant if the code used to generate it is later modified to
plot another figure for instance.
Do you think it would be possible to capture such information with a custom save figure function?
An alternative way would be to use a specific name for each figure. Like, if the code is 'test.m', save the figure as 'test_fig1.png', 'test_fig2.png' , etc. But it would make complicated figures names though.
Neither the print nor the savefig functions provide a way to add a custom parameter to the file details, so I think the most likely way to do this would be to incorporate the information into the file name. It's also the most practical way to do it, since you can see the name without having to open every single file.
Ok, I see!
thanks a lot!

Sign in to comment.

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!