www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@sweepsetfilter/getUserdata.m
function ud = getUserdata(obj, type, index) %GETUSERDATA A short description of the function % % UD = GETUSERDATA(SSF, TYPE, INDEX) gets the userdata for the item % specified by TYPE and INDEX. TYPE determines which type of filter or % variable and INDEX determines the index of the filter or variable within % that type. TYPE must be one of 'variable', 'filter', 'sweepvariable', % 'sweepfilter', 'sweepnote', 'resampling'. If TYPE is 'resampling' then % INDEX has no effect. % % If INDEX is a scalar and TYPE is a string then UD will be exactly the % user data from the filter or variable. % % If INDEX is a vector or TYPE is a cell array of strings (with a single % element), then UD will be a cell array with the user data in. % % UD = GETUSERDATA( SSF, {'TYPE'}, INDEX ) ensures that the returned % objects are in a cell array regardless of the size of index or the % number of objects of the given type. % % See also SWEEPSETFILTER, SWEEPSETFILTER/SETUSERDATA. % Copyright 2000-2005 The MathWorks, Inc. and Ford Global Technologies, Inc. OUTPUT_VALUE = true; if iscell(type) && numel(type) == 1 type = type{1}; OUTPUT_VALUE = false; end if ~ischar(type) error(message('mbc:sweepsetfilter:InvalidArgument1')); end validTypes = {'variable', 'filter', ... 'sweepvariable', 'sweepfilter', ... 'sweepnote', 'resampling'}; typeIndex = find(strcmp(type, validTypes)); if isempty(typeIndex) error(message('mbc:sweepsetfilter:InvalidArgument2', type)); end switch typeIndex case 1 s = obj.variables; case 2 s = obj.filters; case 3 s = obj.sweepVariables; case 4 s = obj.sweepFilters; case 5 s = obj.sweepNotes; case 6 s = obj.resampling; end if nargin < 3 index = 1:length(s); end if typeIndex==6 % Can only index the single resampling data element. index = 1; end if length(index) == 1 && OUTPUT_VALUE ud = s(index).userdata; else ud = {s(index).userdata}; end