Commit b4195c67 authored by Stéphane Adjemian's avatar Stéphane Adjemian

Speed improvement (avoid calls to num2str).

parent 078ca886
......@@ -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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment