People've got an awesome practice of saving figures in the simulation script just after results are finalized.
Its a jolly good habit for all i can tell, since it pretty much prevents a lot of future headache.
No rocket science there..
The function to save a MATLAB figure file "saveas"; can save in several formats including fig (matlab figure), bmp (bitmap - though not recommended), ai (adobe illustrator), psc2 (colored post-script - recommended for latex), so on n so forth.
Fig files are useful in another sense, i.e., the data is automatically secured with it. n i'll show you in a minute -inshAllah- how data could be extracted from the saved fig files;
- Open the saved .fig file using open function. e.g., open abc.fig
- Use gcf to get the current figure pointer/handler and save it in a variable, e.g., h = gcf
- Use get command to get hold of the children of the gcf, H = get(h, 'children')
- Finally, search for the handle of the child which containts all the plots.
- Suppose H(2) is the child with all the plots, then use H2 = get(H(2), 'children')
- Now use set(H2(i)), where i = 1 to number of plots, to list all the properties and change their values.
- Similarly, use the get(H2(i)) to fetch the values of all the properties.
For example, the script below extracts data from the plots.
clear all;
% open the .fig file
open test.fig;
% get the current graph handle
h = gcf;
% get the children of the figure file
H = get(h, 'Children');
% For this specific case the 2nd child has all the plots
H2 = get(H(2), 'Children');
Y = [];
for i = 1:length(H2)
% get the data of y-axis
Y = [Y; get(H2(i), 'YData')];
end
Here is a test.fig, i fiddled with using the above script;
..enjoy.
n happy scripting!
~*~*~*~*~~*~*~*~*~