view m-toolbox/classes/@ao/fromFSfcn.m @ 39:11e3ed9d2115 database-connection-manager

Implement databases listing in database connection dialog
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% FROMFSFCN Construct an ao from a fs-function string
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    fromFSfcn
%
% DESCRIPTION: Construct an ao from a fs-function string
%
% CALL:        a = fromFSfcn(a, pl)
%
% PARAMETER:   pl: Parameter list object
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function a = fromFSfcn(a, pli)
  
  import utils.const.*
  
  VERSION = '$Id: fromFSfcn.m,v 1.24 2011/08/12 12:25:26 hewitson Exp $';
  % get AO info
  ii = ao.getInfo('ao', 'From Frequency-series Function');
  
  % Set the method version string in the minfo object
  ii.setMversion([VERSION '-->' ii.mversion]);
  
  % Add default values
  pl = applyDefaults(ii.plists, pli);
  pl.getSetRandState();
  f  = find(pl, 'f');
  
  if isempty(f)
    utils.helper.msg(msg.PROC2, 'generating f vector');
    f1 = find(pl, 'f1');
    f2 = find(pl, 'f2');
    nf = find(pl, 'nf');
    scale = find(pl, 'scale');
    switch lower(scale)
      case 'log'
        f = logspace(log10(f1), log10(f2), nf);
      case 'lin'
        f = linspace(f1, f2, nf);
      otherwise
        error('### Unknown frequency scale specified');
    end
  elseif isa(f, 'ao')
    f = f.data.getX;
  end
  
  % Get the function
  fcn = find(pl, 'fsfcn');
  
  % make y data
  y = eval([fcn ';']);
  
  fs = fsdata(f,y);
  
  % Make an analysis object
  a.data  = fs;
  
  % Add history
  a.addHistory(ii, pl, [], []);
  
  % set x and y units
  a.setXunits(pl.find('xunits'));
  a.setYunits(pl.find('yunits'));
  
  % Set object properties from the plist
  a.setObjectProperties(pl);
  
end