From 82e765c1dad09ecfb2264730b93158813f7cce58 Mon Sep 17 00:00:00 2001
From: "M. Hock" <martin.hock@fst.tu-darmstadt.de>
Date: Thu, 17 Feb 2022 18:17:06 +0100
Subject: [PATCH] implemented cell flattening and fixxed some type

---
 +PlotID/@dataPath/dataPath.m | 8 ++++++++
 Examples/PlotID_variables.m  | 4 ++--
 PlotID_example.m             | 5 +++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/+PlotID/@dataPath/dataPath.m b/+PlotID/@dataPath/dataPath.m
index 922e3a9..e16488a 100644
--- a/+PlotID/@dataPath/dataPath.m
+++ b/+PlotID/@dataPath/dataPath.m
@@ -14,11 +14,19 @@ classdef dataPath < handle
             %DATAPATH Construct an instance of this class
             %   start with argument validation
             obj.ID = ID;
+            
             %catch non cell inputs in inputPaths 
             if ~iscell(inputPaths)
                   inputPaths = {inputPaths}; %Cell array
             end
             
+
+
+            % handle nested cell arrays
+            while any(cellfun(@iscell,inputPaths))
+                inputPaths = [inputPaths{cellfun(@iscell,inputPaths)} inputPaths(~cellfun(@iscell,inputPaths))]
+            end
+
             isStruct = false([1,numel(inputPaths)]);
             % strings will cause problems, therefore chars are used 
             for i=1:numel(inputPaths)
diff --git a/Examples/PlotID_variables.m b/Examples/PlotID_variables.m
index 9ebc1aa..e24704d 100644
--- a/Examples/PlotID_variables.m
+++ b/Examples/PlotID_variables.m
@@ -24,8 +24,8 @@ plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4]);
 
 s.x =x; s.y=y; % Save both variables in struct s
 
-% Build the locations cell with the struct and one path
-locations =  {s,'test_data.mat'}; 
+% Build the locations cell with the struct and one path or an array of paths
+locations =  {s,datapath}; 
 
 %call publish
 PlotID.Publish(locations,scriptPath, fig1)
diff --git a/PlotID_example.m b/PlotID_example.m
index c944839..33deaf1 100644
--- a/PlotID_example.m
+++ b/PlotID_example.m
@@ -53,6 +53,7 @@ fig2 = figure; plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4]
 % Publish(DataPaths,scriptPath, figure, options)
 
 % Path of the m.script that you use for creating your plot.
+% note: mfilename only works if called from within a script or function
 scriptPath = [mfilename('fullpath'),'.m']; 
 
 % file paths of the datasets used for the plot (don't forget the extension) 
@@ -63,12 +64,12 @@ locations =  datapath;
 %call publish
 PlotID.Publish(locations,scriptPath, fig2)
 
-% Your plot, script and all the data that your provide are now published.
+% Your plot, script and all the data that you provided are now published.
 
 % ---------------------------------
 %% Further examples and help
 % You find more examples in the Examples folder:
-%   - Passing Variables 
+%   - Passing Variables
 %   - Advanced usage 
 %   - Working with HDF5-files
 %   - Using a central data folder
-- 
GitLab