diff --git a/+PlotID/@dataPath/dataPath.m b/+PlotID/@dataPath/dataPath.m index cb52877d31a85ed3e3535a9626644a214e54ac62..67c3edea02d5b76fa8cc16b24dec9514fca2a6a4 100644 --- a/+PlotID/@dataPath/dataPath.m +++ b/+PlotID/@dataPath/dataPath.m @@ -66,7 +66,7 @@ classdef dataPath < handle function cleanTmpFile(obj) if ~isempty(obj.tmpPath) - delete(obj.tmpPath); + delete(obj.tmpPath{:}); end end diff --git a/+PlotID/@dataPath/vars2file.m b/+PlotID/@dataPath/vars2file.m index d82fff0df9de7fe14ff80e62b84ff8e5b850d75b..f7c2ac32194995a5dd3d2ccead02c06e67f600ff 100644 --- a/+PlotID/@dataPath/vars2file.m +++ b/+PlotID/@dataPath/vars2file.m @@ -9,15 +9,24 @@ if ~isfolder(tmpDir) end obj.tmpPath = fullfile(tmpDir,[obj.ID,'_vars.mat']); -% save only the first struct (intended) -struct = obj.DataPaths{isStruct}; -save(obj.tmpPath,'-struct','struct'); +% save each of the structs +for i=1:numel({obj.DataPaths{isStruct}}) + struct = obj.DataPaths{isStruct}; + if i==1 + save(obj.tmpPath,'-struct','struct'); + obj.tmpPath = {obj.tmpPath}; + else + tmpPath = fullfile(tmpDir,[obj.ID,'_vars',num2str(i),'.mat']); + save(tmpPath,'-struct','struct'); + obj.tmpPath{end+1}=tmpPath; + end +end % remove variable from Datapath obj.DataPaths(isStruct) = []; % add tmppath as Datapath -obj.DataPaths{end+1} = obj.tmpPath; +obj.DataPaths = horzcat(obj.DataPaths, obj.tmpPath); end diff --git a/Examples/PlotID_variables.m b/Examples/PlotID_variables.m index e24704d17561d7ce5bd8624bbf8c5e2dbd0168f7..1d34b745d36e96c417bac29ab1550be936cda4d4 100644 --- a/Examples/PlotID_variables.m +++ b/Examples/PlotID_variables.m @@ -15,10 +15,9 @@ plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4]); %% ---- 2. Publishing ----- % You can pass an abitrary number of variables to Publish. -% IMPORTANT: they must be collected and passed in ONE struct -% if multiple structs are passed, only the first one will be stored! +% Passing multiple structs will create multiple data files. % You can additionally add datapaths and combine the methods. -% Passing multiple structs + %Example: Passing the variables x,y to publish diff --git a/README.md b/README.md index 5617565763383af3eea4cbb0b8e7c03bb5765257..f542c31b67ec979fce8e16a9ca6a319ea5b18424 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The **ProjectID** is your custom project number, it well be the prefix of the ID `PlotID.Publish(DataPaths,scriptPath, figure, options)` `scriptPath` contains either the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']` or the script or function name that is used for creating your plot. \ -`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell array (they must be at the path). It is also possible to pass an arbitrary number of variables. All variables **must be** passed in **one** struct. \ +`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell array (they must be at the path). It is also possible to pass an arbitrary number of variables as struct. \ `figure` is the figure that should be published. **Please take also a look on the examples provided in the Example folder**.