2%COPYFIG Create a
copy of a figure, without changing the figure
7% This function will create a
copy of a figure, but not change the figure,
8% as copyobj sometimes does, e.g. by changing legends.
11% fh_old - The handle of the figure to be copied. Default: gcf.
14% fh_new - The handle of the created figure.
16% Copyright (C) Oliver Woodford 2012, Yair Altman 2015
18% 26/02/15: If temp dir is not writable, use the dest folder
for temp
19% destination files (Javier Paredes)
20% 15/04/15: Suppress warnings during copyobj (Dun Kirk comment on FEX page 2013-10-02)
21% 09/09/18: Fix issue #252: Workaround
for cases where copyobj() fails for any reason
28 useCopyobj = isempty(findall(fh, 'Type', 'axes', 'Tag', 'legend'));
30 % Safe to
copy using copyobj
31 oldWarn = warning('off'); %Suppress warnings during copyobj (Dun Kirk comment on FEX page 2013-10-02)
35 % Fix issue
#252: Workaround for cases where copyobj() fails for any reason
36 useCopyobj =
false; %
if copyobj() croaks, use file save/load below
41 % copyobj will change the figure, so save and then load it instead
42 tmp_nam = [tempname '.fig'];
44 % Ensure that the temp dir is writable (Javier Paredes 26/2/15)
45 fid = fopen(tmp_nam,'w');
50 % Temp dir is not writable, so use the current folder
51 [dummy,fname,fext] = fileparts(tmp_nam); %
#ok<ASGLU>
53 tmp_nam = fullfile(fpath,[fname fext]);
function cleanup(in cmdfile)
function copy(in from, in to, in field, in exclude)
Copy the contents of the struct/object from to the struct/object to recursively and without destroyin...