Commit f258ffbf authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Check the name of the data file in @dynSeries/save method (do not erase the original data file).

parent 28f3ca1d
......@@ -28,7 +28,11 @@ end
switch format
case 'm'
fid = fopen([basename, '.m'],'w');
if exist([basename, '.m'],'file')
fid = fopen([basename, '.new', '.m'],'w');
else
fid = fopen([basename, '.m'],'w');
end
fprintf(fid,'%% File created on %s.\n',datestr(now));
fprintf(fid,'\n');
fprintf(fid,'FREQ__ = %s;\n',num2str(A.freq));
......@@ -66,9 +70,18 @@ switch format
str = [str, A.name{v} ' = A.data(:,' num2str(v) ');' ];
end
eval(str);
save([basename '.mat'],'INIT__','FREQ__','NAMES__','TEX__',A.name{:});
if exist([basename, '.mat'],'file')
save([basename '.new.mat'],'INIT__','FREQ__','NAMES__','TEX__',A.name{:});
else
save([basename '.mat'],'INIT__','FREQ__','NAMES__','TEX__',A.name{:});
end
case 'csv'
fid = fopen([basename, '.csv'],'w');
if exist([basename, '.csv'],'file')
fid = fopen([basename, '.new', '.csv'],'w');
else
fid = fopen([basename, '.csv'],'w');
end
fprintf(fid,', %s', A.name{:});
fprintf(fid,'\n');
for t=1:A.nobs
......
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