Home > classes > @ltpda_uoh > fromFile.m

fromFile

PURPOSE ^

Construct a ltpda_ob from a file

SYNOPSIS ^

function objs = fromFile(obj, pli)

DESCRIPTION ^

 Construct a ltpda_ob from a file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromFile

 DESCRIPTION: Construct a ltpda_ob from a file

 CALL:        obj = obj.fromFile(filename)
              obj = obj.fromFile(pl)

 VERSION:     $Id: fromFile.m,v 1.3 2008/09/08 09:40:46 hewitson Exp $

 HISTORY:     21-08-2008 Diepholz
              Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Construct a ltpda_ob from a file
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % FUNCTION:    fromFile
0005 %
0006 % DESCRIPTION: Construct a ltpda_ob from a file
0007 %
0008 % CALL:        obj = obj.fromFile(filename)
0009 %              obj = obj.fromFile(pl)
0010 %
0011 % VERSION:     $Id: fromFile.m,v 1.3 2008/09/08 09:40:46 hewitson Exp $
0012 %
0013 % HISTORY:     21-08-2008 Diepholz
0014 %              Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 function objs = fromFile(obj, pli)
0018 
0019   VERSION = '$Id: fromFile.m,v 1.3 2008/09/08 09:40:46 hewitson Exp $';
0020 
0021   % Which file type are we dealing with?
0022   if ischar(pli)
0023     pli = plist('filename', pli);
0024   end
0025 
0026   % get filename
0027   filename = find(pli, 'filename');
0028 
0029   % Get the correct parameter set
0030   [path, name, ext] = fileparts(filename);
0031 
0032   switch ext
0033 
0034     case '.fil'
0035       objs = obj.fromLISO(pli);
0036 
0037     case '.mat'
0038       ii = obj.getInfo(class(obj), 'From MAT File');
0039       ii.setMversion([VERSION '-->' ii.mversion]);
0040       objs = load(filename);
0041       
0042       if isstruct(objs) && isfield(objs, 'objs')
0043         scl = utils.helper.classFromStruct(objs.objs);
0044         if isempty(scl)
0045           error('### The structure does not match any LTPDA object.');
0046         end
0047         if ~strcmp(class(obj), scl)
0048           error('### The structure does not match the chosen LTPDA object constructor. It seems to be a [%s] object.', scl)
0049         end           
0050         objs = feval(class(obj), objs.objs);
0051         objs.addHistory(ii, pli, [], []);
0052       elseif ismember('a', fieldnames(objs))
0053         objs = objs.a;
0054         objs.addHistory(ii, pli, [], []);
0055       elseif ismember('objs', fieldnames(objs))
0056         objs = objs.objs;
0057         objs.addHistory(ii, pli, [], []);
0058       else
0059         objs = obj.fromDataInMAT(objs, pli);
0060       end
0061 
0062     case '.xml'
0063       root_node = xmlread(filename);
0064       objs = utils.helper.xmlread(root_node, class(obj));
0065 
0066     case {'.txt', '.dat'}
0067       % Add default values
0068       objs = obj.fromDatafile(pli);
0069 
0070     otherwise
0071       error('### Unknown file type [%s].', ext(2:end));
0072   end
0073 
0074 end
0075

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003