Home > classes > @ao > fromDataInMAT.m

fromDataInMAT

PURPOSE ^

FROMDATAINMAT Convert a saved data-array into an AO with a tsdata-object

SYNOPSIS ^

function obj = fromDataInMAT(obj, data, pli)

DESCRIPTION ^

 FROMDATAINMAT Convert a saved data-array into an AO with a tsdata-object
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromDataInMAT

 DESCRIPTION: Convert a saved data-array into an AO with a tsdata-object

 CALL:        obj = fromLISO(obj, data-array, plist)

 PARAMETER:   data-array: data-array
              plist:      plist-object (must contain the filename)

 VERSION:     $Id: fromDataInMAT.m,v 1.1 2008/08/22 14:17:26 ingo Exp $

 HISTORY:     22-03-2008 M Hewitson
              Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % FROMDATAINMAT Convert a saved data-array into an AO with a tsdata-object
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % FUNCTION:    fromDataInMAT
0005 %
0006 % DESCRIPTION: Convert a saved data-array into an AO with a tsdata-object
0007 %
0008 % CALL:        obj = fromLISO(obj, data-array, plist)
0009 %
0010 % PARAMETER:   data-array: data-array
0011 %              plist:      plist-object (must contain the filename)
0012 %
0013 % VERSION:     $Id: fromDataInMAT.m,v 1.1 2008/08/22 14:17:26 ingo Exp $
0014 %
0015 % HISTORY:     22-03-2008 M Hewitson
0016 %              Creation
0017 %
0018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0019 
0020 function obj = fromDataInMAT(obj, data, pli)
0021 
0022   VERSION = '$Id: fromDataInMAT.m,v 1.1 2008/08/22 14:17:26 ingo Exp $';
0023 
0024   ii = obj.getInfo(class(obj), 'From MAT File');
0025 
0026   % Set the method version string in the minfo object
0027   ii.setMversion([VERSION '-->' ii.mversion]);
0028 
0029   % Then we try for a numerical data set in
0030   % the first numerical field we come to
0031   fnames = fieldnames(data);
0032   for jj=1:length(fnames)
0033     if isnumeric(data.(fnames{jj}))
0034       % get the data from here
0035       data = data.(fnames{jj});
0036       ss = size(data);
0037       if ss(1) > 2
0038         warning('!!! I can only handle data files with two columns: time and amplitude. Additional columns are ignored.');
0039       end
0040       if ss(1) > ss(2)
0041         data = data.';
0042       end
0043       if ss(1) < 2
0044         x  = data(1,:);
0045         fs = 1;
0046         data_obj = tsdata(x, fs);
0047       else
0048         % t from column 1
0049         t = data(1,:);
0050         % x from column 2
0051         x = data(2,:);
0052         data_obj = tsdata(t,x);
0053       end
0054 
0055       obj.data = data_obj;
0056 
0057       % ignore the other fields
0058       warning('!!! Found a numeric field called %s. Ignoring all others.', fnames{jj});
0059 
0060       obj.setName(find(pli, 'filename'), 'internal');
0061       obj.addHistory(ii, pli, [], []);
0062       break;
0063     end
0064   end
0065 
0066 end
0067

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