Skip to content

Commit

Permalink
Converted arg2str to local function to remove external dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
widmann committed Aug 7, 2017
1 parent 32bb786 commit a14bd49
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pop_bdfread.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,41 @@
end

end

function str = arg2str(arg)

if isstruct(arg)
str = '';
fieldArray = fieldnames(arg);
arg = struct2cell(arg);
for iArg = 1:length(arg)
if ischar(arg{iArg})
str = [str '''' fieldArray{iArg} ''', ''' arg{iArg} ''''];
elseif isnumeric(arg{iArg}) || islogical(arg{iArg})
str = [str '''' fieldArray{iArg} ''', ' mat2str(arg{iArg})];
elseif iscell(arg{iArg})
str = [str '''' fieldArray{iArg} ''', ' arg2str(arg{iArg})];
end
if iArg < length(arg)
str = [str ', '];
end
end
elseif iscell(arg)
str = '{';
for iArg = 1:length(arg)
if ischar(arg{iArg})
str = [str '''' arg{iArg} ''''];
elseif isnumeric(arg{iArg}) || islogical(arg{iArg})
str = [str mat2str(arg{iArg})];
elseif iscell(arg{iArg})
str = [str arg2str(arg{iArg})];
end
if iArg < length(arg)
str = [str ' '];
else
str = [str '}'];
end
end
end

end

0 comments on commit a14bd49

Please sign in to comment.