Skip to content
Snippets Groups Projects
Commit 835a70f6 authored by M. Hock's avatar M. Hock
Browse files

implemented handling of multiple structures

parent d8ce3500
No related branches found
No related tags found
2 merge requests!62Introduce changes for V1.0 RC 1,!54Dev/datapath handle all structs
Pipeline #650841 passed
......@@ -66,7 +66,7 @@ classdef dataPath < handle
function cleanTmpFile(obj)
if ~isempty(obj.tmpPath)
delete(obj.tmpPath);
delete(obj.tmpPath{:});
end
end
......
......@@ -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
......@@ -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
......
......@@ -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**.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment