-
Notifications
You must be signed in to change notification settings - Fork 0
/
saveFigure.m
33 lines (26 loc) · 844 Bytes
/
saveFigure.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function filename = saveFigure(figure, varargin)
% SAVEFIGURE Save a figure to the current directory in two formats (*.fig and *.eps).
%
% SAVEFIGURE(FIGURE) generates a filename and saves the figure FIGURE to the associated file.
%
% SAVEFIGURE(FIGURE, FILENAME) saves the figure FIGURE to the file FILENAME
%
% Input:
% figure - Figure to be saved
% filename - (Optional) String containing filename
%
% Output:
% filename - Filename
%
% Author: Christian Schwarzer - SSC EPFL
% CreationDate: 25.11.2002 LastModified: 20.01.2003
switch nargin
case 1
filename = datestr(now,'yyyymmddTHHMMSS');
case 2
filename = varargin{1};
otherwise
error('Wrong number of arguments. Type: help saveFigure')
end
saveas(figure, filename, 'fig');
saveas(figure, filename, 'eps');