@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))) ...@@ -305,54 +305,54 @@ if ~all(cellfun(@isempty, struct2cell(o.estimate)))
r = r+1; r = r+1;
end end
o.results.(savedoutput{i}) = fileread(sprintf('%s.estx', basename)); o.results.(savedoutput{i}) = fileread(sprintf('%s.estx', basename));
else elseif lower(savedoutput{i}) == 'mdl'
tmp = importdata(sprintf('%s.%s', basename, lower(savedoutput{i})), '\t'); o.results.(savedoutput{i}) = fileread(sprintf('%s.mdl', basename));
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}) == 'rcm' elseif lower(savedoutput{i}) == 'rcm'
o.results.(savedoutput{i}) = fileread(sprintf('%s.rcm', basename)); o.results.(savedoutput{i}) = fileread(sprintf('%s.rcm', basename));
elseif lower(savedoutput{i}) == 'acm' elseif lower(savedoutput{i}) == 'acm'
o.results.(savedoutput{i}) = fileread(sprintf('%s.acm', basename)); o.results.(savedoutput{i}) = fileread(sprintf('%s.acm', basename));
elseif lower(savedoutput{i}) == 'rts' else % Files that can be read with importdata
header = strjoin(tmp.textdata(1,1)); tmp = importdata(sprintf('%s.%s', basename, lower(savedoutput{i})), '\t');
header = strsplit(header, {'\t'}); data = tmp.data;
info = tmp.textdata(3:end,1:2);
for j = 1:rows(data) if lower(savedoutput{i}) == 'lks'
for k = 1:columns(info) for j = 1:numel(tmp.textdata)
o.results.(savedoutput{i}).(['root_' num2str(j)]).(header{k}) = strjoin(info(j,k)); o.results.(savedoutput{i}).(tmp.textdata{j}) = data(j);
end end
for k = 1:columns(data) elseif lower(savedoutput{i}) == 'ref'
o.results.(savedoutput{i}).(['root_' num2str(j)]).(header{k+columns(info)}) = data(j,k); 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
end elseif lower(savedoutput{i}) == 'rrs'
elseif lower(savedoutput{i}) == 'itr' o.results.(savedoutput{i}) = dseries(data(:,2), o.y.init, savedoutput{i});
data = data(:,3:end); elseif lower(savedoutput{i}) == 'rsd'
header = strjoin(tmp.textdata(1,1)); o.results.(savedoutput{i}) = dseries(data(:,2), o.y.init, savedoutput{i});
header = strsplit(header, {'\t'}); elseif lower(savedoutput{i}) == 'rts'
header = header(3:end-1); header = strjoin(tmp.textdata(1,1));
for j = 1:rows(data) header = strsplit(header, {'\t'});
for k = 1:columns(header) info = tmp.textdata(3:end,1:2);
o.results.(savedoutput{i}).(['iter_' num2str(j)]).(header{k}) = data(j,k); 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
end end
elseif lower(savedoutput{i}) == 'mdl'
o.results.(savedoutput{i}) = fileread(sprintf('%s.mdl', basename));
end end
end end
end end
...@@ -374,4 +374,4 @@ if ~all(cellfun(@isempty, struct2cell(o.history))) ...@@ -374,4 +374,4 @@ if ~all(cellfun(@isempty, struct2cell(o.history)))
end end
% Save main generated output file. % Save main generated output file.
o.results.out = fileread(sprintf('%s.out', basename)); o.results.out = fileread(sprintf('%s.out', basename));
\ No newline at end of file
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