From ef30fe653205af43c66923d69a67c62676bcf055 Mon Sep 17 00:00:00 2001 From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de> Date: Fri, 12 Nov 2021 09:07:52 +0100 Subject: [PATCH] Add #82, fix #81 --- +PlotID/Publish.m | 27 +++++++++++++++++++-------- example.m | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index 34917d3..6cf4623 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -33,6 +33,18 @@ arguments end %% argument validation +%catch string and non cell inputs in DataPaths +if ~iscell(DataPaths) + DataPaths = {DataPaths}; %Cell array +end + +for i=1:numel(DataPaths) + if isstring(DataPaths{i}); + % strings will cause problems + DataPaths{i} = char(DataPaths{i}); + end +end + %catch multiple figures in fig if numel(figure) > 1 figure = figure(1); @@ -248,14 +260,13 @@ end function mustBeDataPath(DataPaths) %checks if input is a valid DataPath object - - if isstring(DataPaths) - tf = zeros(1,numel(DataPaths)); - for i=1:numel(DataPaths) - tf(i) = ~isfile(DataPaths{i}); - end - else - tf = ~isfile(DataPaths); + if ~iscell(DataPaths) + DataPaths = {DataPaths}; + end + tf = zeros(1,numel(DataPaths)); + + for i=1:numel(DataPaths) + tf(i) = ~isfile(DataPaths{i}); end if any(tf) diff --git a/example.m b/example.m index 6ef682a..3f86ce5 100644 --- a/example.m +++ b/example.m @@ -76,8 +76,8 @@ scriptPath = [mfilename('fullpath'),'.m']; %(defined above:) dataset1 = 'test_data.mat'; dataset2 = 'testdata2.h5' locations = {dataset1,dataset2} ; % don't forget the extension +locations = {string(dataset1),dataset2} -%locations = {'test_data.mat', 'falsch'}; %call publishing PlotID.Publish(locations,scriptPath, fig(1), 'Location', 'local' ,'Method','individual') -- GitLab