Mercurial > hg > ltpda
diff m-toolbox/classes/@ao/fromFSfcn.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@ao/fromFSfcn.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,69 @@ +% 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 +