Home > classes > @ao > export.m

export

PURPOSE ^

EXPORT export an analysis object to a text file.

SYNOPSIS ^

function varargout = export(varargin)

DESCRIPTION ^

 EXPORT export an analysis object to a text file.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: EXPORT export an analysis object to a text file.

 CALL:        export(a, 'blah.txt');
              export(a, plist);

 VERSION:     $Id: export.html,v 1.14 2008/03/31 10:27:34 hewitson Exp $

 HISTORY: 30-03-07 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = export(varargin)
0002 % EXPORT export an analysis object to a text file.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: EXPORT export an analysis object to a text file.
0007 %
0008 % CALL:        export(a, 'blah.txt');
0009 %              export(a, plist);
0010 %
0011 % VERSION:     $Id: export.html,v 1.14 2008/03/31 10:27:34 hewitson Exp $
0012 %
0013 % HISTORY: 30-03-07 M Hewitson
0014 %             Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 VERSION  = '$Id: export.html,v 1.14 2008/03/31 10:27:34 hewitson Exp $';
0019 CATEGORY = 'Output';
0020 
0021 %% Check if this is a call for parameters
0022 if nargin == 2
0023   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0024     in = char(varargin{2});
0025     if strcmp(in, 'Params')
0026       varargout{1} = plist('filename', 'foo.txt');
0027       return
0028     elseif strcmp(in, 'Version')
0029       varargout{1} = VERSION;
0030       return
0031     elseif strcmp(in, 'Category')
0032       varargout{1} = CATEGORY;
0033       return
0034     end
0035   end
0036 end
0037 
0038 
0039 %% Get inputs and proceed
0040 a        = varargin{1};
0041 % get filename from plist
0042 if isa(varargin{2}, 'plist')
0043   filename = find(varargin{2}, 'filename');
0044 else % or directly
0045   filename = varargin{2};
0046 end  
0047 if isempty(filename)
0048   error('### You must specify a filename. Either directly, or in a plist');
0049 end
0050 
0051 if length(a) > 1
0052   error('### I can only deal with one AO at a time.');
0053 end
0054 
0055 
0056 if isa(a, 'ao')
0057 
0058   [x,y] = get_xy_values(a.data);
0059 
0060   if isreal(y)
0061     out = [x y];
0062   else
0063     out = [x real(y) imag(y)];
0064   end
0065 
0066   save(filename, 'out', '-ASCII', '-DOUBLE', '-TABS');
0067 
0068 else
0069   error('### incorrect usage: first argument should be an AO.');
0070 end
0071 
0072 % END
0073

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003