You are on page 1of 2

http://people.maths.ox.ac.uk/moorep/tis.

%
% Purpose:
% Simple MATLAB wrapper for TISEAN
%
% Input
% tiscmd - character array of TISEAN command name
% tisparms - character array of TISEAN parameters
% y - vector input
%
% Effects:
% Returns output of TISEAN command
%
% Usage examples
%
% r1 = tis('lzo-run','-m1,4 -d8 -L200 -V0',amplitude(1:end-200));
% r1 = tis('henon','-B0 -A1.43 -l1000');
% r1 = tis('xzero',['-m3 -d1 -k2 -s20 -V1 -s',num2str(npreds)],z);
%
% This code probably won't work for all TISEAN commands.
% Please adapt as necessary.
%
% (c) 2009 Paul Moore - moorep@maths.ox.ac.uk
%
% This software is provided 'as is' with no warranty or other guarantee of
% fitness for the user's purpose. Please let the author know of any bugs
% or potential improvements.

function result = tis(tiscmd, tisparms, y)

MAXCOLS = 16;

ythere = nargin == 3;

% Set tiseanPath to the location of the executable


%tiseanPath = 'C:\Progra~1\Tisean_3.0.0\bin\';
tiseanPath = 'N:\research\Tisean_3.0.0\bin\';

infn = 'tempin001.txt';
outfn = 'tempout001.dat';

delete (outfn);

if (ythere)
delete (infn);

% save variable in ascii format


fid = fopen(infn, 'w');
[yr yc] = size(y);
for i=1:yr
fmat = [repmat('%f ',1,yc) '\n'];
fprintf(fid, fmat, y(i,:));
end
fclose(fid);
infileparm = [' ',infn,' '];
else
infileparm = ' ';
end

% -o <fn> output file name


syscmd = [tiseanPath,tiscmd,infileparm,tisparms,' -o ', outfn];
system(syscmd);

% load output file into a cell array


fstr = repmat('%f ',1, MAXCOLS);
fid = fopen(outfn);
cellset = textscan(fid, fstr, 'CommentStyle', '#', 'CollectOutput', 0); % ignore data after #
fclose(fid);

% empty columns are filled with NaNs


for i=1:MAXCOLS
ri = cellset{i};

1 of 2 6/17/2012 12:58 AM
http://people.maths.ox.ac.uk/moorep/tis.m

if ~isnan(ri(1))
result(:,i) = ri;
end
end

if (ythere)
delete (infn);
end
%delete (outfn);
end

2 of 2 6/17/2012 12:58 AM

You might also like