@x13/run.m: compatibility fix for Octave

Previously, .mdl files would unnecessarily be passed through importdata(),
which crashes on Octave.

The nested “if”s (testing for the output file extension) have been reorganized,
so that importdata() is not called on .mdl files (and neither on .acm and .rcm,
where is not needed either).
parent fc358e91
Pipeline #1872 passed with stage
in 2 minutes and 8 seconds
......@@ -305,54 +305,54 @@ if ~all(cellfun(@isempty, struct2cell(o.estimate)))
r = r+1;
end
o.results.(savedoutput{i}) = fileread(sprintf('%s.estx', basename));
else
tmp = importdata(sprintf('%s.%s', basename, lower(savedoutput{i})), '\t');
data = tmp.data;
end
if lower(savedoutput{i}) == 'lks'
for j = 1:numel(tmp.textdata)
o.results.(savedoutput{i}).(tmp.textdata{j}) = data(j);
end
elseif lower(savedoutput{i}) == 'ref'
header = strjoin(tmp.textdata(1,1));
header = strsplit(header, {'\t'});
header = regexprep(header(1,2:end),'( ||\-)','');
for j = 1:numel(header)
o.results.(savedoutput{i}).(header{j}) = dseries(data(:,j+1), o.y.init, header(j));
end
elseif lower(savedoutput{i}) == 'rrs'
o.results.(savedoutput{i}) = dseries(data(:,2), o.y.init, savedoutput{i});
elseif lower(savedoutput{i}) == 'rsd'
o.results.(savedoutput{i}) = dseries(data(:,2), o.y.init, savedoutput{i});
elseif lower(savedoutput{i}) == 'mdl'
o.results.(savedoutput{i}) = fileread(sprintf('%s.mdl', basename));
elseif lower(savedoutput{i}) == 'rcm'
o.results.(savedoutput{i}) = fileread(sprintf('%s.rcm', basename));
elseif lower(savedoutput{i}) == 'acm'
o.results.(savedoutput{i}) = fileread(sprintf('%s.acm', basename));
elseif lower(savedoutput{i}) == 'rts'
header = strjoin(tmp.textdata(1,1));
header = strsplit(header, {'\t'});
info = tmp.textdata(3:end,1:2);
for j = 1:rows(data)
for k = 1:columns(info)
o.results.(savedoutput{i}).(['root_' num2str(j)]).(header{k}) = strjoin(info(j,k));
else % Files that can be read with importdata
tmp = importdata(sprintf('%s.%s', basename, lower(savedoutput{i})), '\t');
data = tmp.data;
if lower(savedoutput{i}) == 'lks'
for j = 1:numel(tmp.textdata)
o.results.(savedoutput{i}).(tmp.textdata{j}) = data(j);
end
for k = 1:columns(data)
o.results.(savedoutput{i}).(['root_' num2str(j)]).(header{k+columns(info)}) = data(j,k);
elseif lower(savedoutput{i}) == 'ref'
header = strjoin(tmp.textdata(1,1));
header = strsplit(header, {'\t'});
header = regexprep(header(1,2:end),'( ||\-)','');
for j = 1:numel(header)
o.results.(savedoutput{i}).(header{j}) = dseries(data(:,j+1), o.y.init, header(j));
end
end
elseif lower(savedoutput{i}) == 'itr'
data = data(:,3:end);
header = strjoin(tmp.textdata(1,1));
header = strsplit(header, {'\t'});
header = header(3:end-1);
for j = 1:rows(data)
for k = 1:columns(header)
o.results.(savedoutput{i}).(['iter_' num2str(j)]).(header{k}) = data(j,k);
elseif lower(savedoutput{i}) == 'rrs'
o.results.(savedoutput{i}) = dseries(data(:,2), o.y.init, savedoutput{i});
elseif lower(savedoutput{i}) == 'rsd'
o.results.(savedoutput{i}) = dseries(data(:,2), o.y.init, savedoutput{i});
elseif lower(savedoutput{i}) == 'rts'
header = strjoin(tmp.textdata(1,1));
header = strsplit(header, {'\t'});
info = tmp.textdata(3:end,1:2);
for j = 1:rows(data)
for k = 1:columns(info)
o.results.(savedoutput{i}).(['root_' num2str(j)]).(header{k}) = strjoin(info(j,k));
end
for k = 1:columns(data)
o.results.(savedoutput{i}).(['root_' num2str(j)]).(header{k+columns(info)}) = data(j,k);
end
end
elseif lower(savedoutput{i}) == 'itr'
data = data(:,3:end);
header = strjoin(tmp.textdata(1,1));
header = strsplit(header, {'\t'});
header = header(3:end-1);
for j = 1:rows(data)
for k = 1:columns(header)
o.results.(savedoutput{i}).(['iter_' num2str(j)]).(header{k}) = data(j,k);
end
end
end
elseif lower(savedoutput{i}) == 'mdl'
o.results.(savedoutput{i}) = fileread(sprintf('%s.mdl', basename));
end
end
end
......@@ -374,4 +374,4 @@ if ~all(cellfun(@isempty, struct2cell(o.history)))
end
% Save main generated output file.
o.results.out = fileread(sprintf('%s.out', basename));
\ No newline at end of file
o.results.out = fileread(sprintf('%s.out', basename));
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