-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXfigureExport.m
57 lines (48 loc) · 1.8 KB
/
XfigureExport.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function XfigureExport(figureTitle, DisplayFigure)
% XfigureExport - saves the xFigureObject in the current workspace to the
% StreamingAssets folder of the MatlabViewer app.
%
% Syntax:
% XfigureExport()
% XfigureExport(figureTitle)
% XfigureExport(figureTitle, DisplayFigure)
%
% Inputs:
% figureTitle - string; file name for the figure to be saved as
% Default = 'Xfigure';
% DisplayFigure - bool; if true the app will be launched (to display the
% figure it will still need to be selected by name from the dropdown
% menu and rendered using by clicking "Update Figure")
% Default = false;
%
% Author: J. Benjamin Kacerovsky
% Centre for Research in Neuroscience, McGill University
% email: johannes.kacerovsky@mail.mcgill.ca
% Created: 02-Sep-2020 ; Last revision: 02-Sep-2020
% ------------- BEGIN CODE --------------
if nargin < 1
figureTitle = "Xfigure";
end
if nargin < 2
DisplayFigure = false;
end
% enforce no white spaces in file names
% bad practice and XfigureClear will have issues
figureTitle = strrep(figureTitle, '\s', '_');
path = fileparts(mfilename('fullpath'));
if ismac
path = strcat(path, '/MatLabViewer_Mac.app/Contents/Resources/Data/StreamingAssets/', figureTitle);
elseif isunix
path = strcat(path, '/MatLabViewer_Linux/MatLabViewer_Linux_Data/StreamingAssets/', figureTitle);
elseif ispc
path = strcat(path, '\MatLabViewer_Windows\MatlabViewer_Data\StreamingAssets\', figureTitle);
else
fprintf("save path not defined for this OS\n");
end
xFigureObject = evalin('base', "xFigureObject");
save(path, "xFigureObject");
if DisplayFigure == true
XfigureDisplay
end
end
% ------------- END OF CODE --------------