From b4195c67b67134ef533721f9de0f4718c23fe810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= <stepan@adjemian.eu> Date: Thu, 5 Dec 2019 11:38:37 +0100 Subject: [PATCH] Speed improvement (avoid calls to num2str). --- src/@dseries/save.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/@dseries/save.m b/src/@dseries/save.m index 52c678b..8f4bb0f 100644 --- a/src/@dseries/save.m +++ b/src/@dseries/save.m @@ -36,7 +36,7 @@ switch format fid = fopen([basename, '.m'],'w'); fprintf(fid,'%% File created on %s.\n',datestr(now)); fprintf(fid,'\n'); - fprintf(fid,'FREQ__ = %s;\n',num2str(frequency(o))); + fprintf(fid,'FREQ__ = %u;\n', frequency(o)); fprintf(fid,'INIT__ = ''%s'';\n',date2string(firstdate(o))); fprintf(fid,'\n'); fprintf(fid,'NAMES__ = {'); @@ -74,13 +74,13 @@ switch format tagnames = fieldnames(o.tags); fprintf(fid, 'TAGS__ = struct();\n'); for i=1:length(tagnames) - fprintf(fid, 'TAGS__.%s = cell(%s, 1);\n', tagnames{i}, num2str(vobs(o))); + fprintf(fid, 'TAGS__.%s = cell(%u, 1);\n', tagnames{i}, vobs(o)); for j=1:vobs(o) if ~isempty(o.tags.(tagnames{i}){j}) if ischar(o.tags.(tagnames{i}){j}) - fprintf(fid, 'TAGS__.%s(%s) = {''%s''};\n', tagnames{i}, num2str(j), o.tags.(tagnames{i}){j}); + fprintf(fid, 'TAGS__.%s(%u) = {''%s''};\n', tagnames{i}, j, o.tags.(tagnames{i}){j}); elseif isnumeric(o.tags.(tagnames{i}){j}) && iscalar(o.tags.(tagnames{i}){j}) - fprintf(fid, 'TAGS__.%s(%s) = {%s};\n', tagnames{i}, num2str(j), o.tags.(tagnames{i}){j}); + fprintf(fid, 'TAGS__.%s(%u) = {%s};\n', tagnames{i}, j, o.tags.(tagnames{i}){j}); else error('dseries::tags: Cannot save this type of tag!') end @@ -105,7 +105,7 @@ switch format TAGS__ = o.tags; str = []; for v = 1:vobs(o) - str = sprintf('%s %s = o.data(:,%s);', str, o.name{v}, num2str(v)); + str = sprintf('%s %s = o.data(:,%u);', str, o.name{v}, v); end eval(str); currentdirectorycontent = dir(); -- GitLab