| 19 |
tfile=sprintf('/tmp/grepexpr%15.15f',rand); |
tfile=sprintf('/tmp/grepexpr%15.15f',rand); |
| 20 |
for k=1:nargin-1; |
for k=1:nargin-1; |
| 21 |
try |
try |
| 22 |
eval(['!grep ' varargin{k} ' ' file ' | sed s/.\*=// | sed s/NAN/1.23456789/ >! ' tfile]) |
eval(['!grep ' varargin{k} ' ' file ' | sed s/.\*=// | sed s/NAN/1.23456789/ > ' tfile]) |
| 23 |
vals(:,k)=textread(tfile,'%f'); |
|
| 24 |
|
% vals(:,k)=textread(tfile,'%f'); |
| 25 |
|
|
| 26 |
|
% When output file is from an ongoing integration, one or more of |
| 27 |
|
% the diagnostics may be missing at the last available time step. |
| 28 |
|
% The code below accomodates this difference in length. |
| 29 |
|
|
| 30 |
|
if k==1 |
| 31 |
|
vals(:,k)=textread(tfile,'%f'); |
| 32 |
|
lngt=length(vals(:,k)); |
| 33 |
|
else |
| 34 |
|
tmp=textread(tfile,'%f'); |
| 35 |
|
% allow |
| 36 |
|
if abs(length(tmp)-lngt)>1 |
| 37 |
|
error(sprintf('An error occured while scanning for: %s',varargin{k})); |
| 38 |
|
else |
| 39 |
|
lngt=min(lngt,length(tmp)); |
| 40 |
|
vals(1:lngt,k)=tmp(1:lngt); |
| 41 |
|
end |
| 42 |
|
|
| 43 |
|
end |
| 44 |
delete(tfile) |
delete(tfile) |
| 45 |
catch |
catch |
| 46 |
delete(tfile) |
delete(tfile) |
| 47 |
error(sprintf('An error occured while scanning for: %s',varargin{k})); |
error(sprintf('An error occured while scanning for: %s',varargin{k})); |
| 48 |
end |
end |
| 49 |
end |
end |
| 50 |
|
vals=vals(1:lngt,:); |