www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@sweepsetfilter/get.m

    function values = get(obj, Properties, index)
%GET Get a propertyvalue
%
%  VAL = GET(OBJ, PROP,  INDEX) gets a property from the sweepsetfilter.
%  If the property is a vector and INDEX is supplied, the return value will
%  be an index into the property.

%  Copyright 2000-2014 The MathWorks, Inc. and Ford Global Technologies, Inc.


valid_props = {'filters' 'variables' 'removedrecords' 'varsweepset' 'reordersweeps' 'label'...
		'date' 'comment' 'keepvariables' 'definetests' 'notes' 'sweepnotes' 'cache' 'sweepfilters' 'removedsweeps'...
        'serializefilters' 'serializevariables' 'serializesweepfilters' 'serializesweepnotes' ...
        'guidfilters', 'modifieddata', 'sweepvariables', 'serializesweepvariables', 'resampling', 'serializeresampling'};

% Have we got any properties?
ALLPROPS = nargin < 2;
if ALLPROPS
	Properties = valid_props;
end

% Have we been given an index value
INDEXED = nargin > 2;

ISCHAR = ischar(Properties);
if ISCHAR
	Properties = {Properties};
end

values = cell(1,length(Properties));
Properties = lower(Properties);


for i = 1:length(Properties)
	property = Properties{i};
	mInd = find( strncmp( property,valid_props,length(property) ) );
	if length(mInd) > 1
        error(message('mbc:sweepsetfilter:InvalidPropertyName', property));
	end
	if isempty(mInd)
		% Are any properties to be got from the object being filtered
		ss = sweepset(obj);
		% MAX and MIN need to be re-initialised before getting
		if strcmp(property, 'MIN') || strcmp(property, 'MAX')
			ss = SetMinMax(ss);
		end
		values{i} = get(ss, property);
	else	
		switch mInd
		case 1
			% filters
			values{i} = obj.filters;
			if INDEXED
				values{i} = values{i}(index);
			end
		case 2
			% variables
			values{i} = obj.variables;
			if INDEXED
				values{i} = values{i}(index);
			end
		case 3
			% removedRecords
			values{i} = obj.recordsToRemove;
		case 4
			% varSweepset
			values{i} = obj.variableSweepset;
		case 5
			% Reorder variable
			values{i} = obj.reorderSweeps;
		case 6
			% Label (not name because sweepset has 'name')
			values{i} = obj.name;
		case 7
			% Date
			values{i} = obj.date;
		case 8
			% Comment
			values{i} = obj.comment;
		case 9
			% keep variables
			values{i} = obj.variablesToKeep;
		case 10
			% Define Tests
			values{i} = obj.defineTests;
        case 11
            % Notes
            values{i} = i_getAllSweepNotes(obj);
        case 12
            % SweepNotes
            values{i} = obj.sweepNotes;
			if INDEXED
				values{i} = values{i}(index);
			end
        case 13
            % Cache state
            values{i} = obj.allowsCacheing;
        case 14
            % Sweep filters
            values{i} = obj.sweepFilters;
			if INDEXED
				values{i} = values{i}(index);
			end
		case 15
			% removedSweeps
            if iscell(obj.sweepsToRemove) && numel(obj.sweepsToRemove)==2
                values{i} = obj.sweepsToRemove{2};
            else
                values{i} = obj.sweepsToRemove;
            end
        case 16
            % serializefilters
            values{i} = {obj.filters.filterExp}.';
        case 17
            % serializevariables
            values{i} = [ {obj.variables.varString}.' {obj.variables.varUnit}.' ];
        case 18
            % serializesweepfilters
            values{i} = {obj.sweepFilters.filterExp}.';
        case 19
            % serializesweepnotes
            values{i} = [ {obj.sweepNotes.noteExp}.' {obj.sweepNotes.noteString}.' {obj.sweepNotes.noteColor}.'];
        case 20
            % guid filter
            values{i} = obj.filterGuid;
        case 21
            % modified data
            values{i} = obj.modifiedData;
        case 22
            % sweep variables
            values{i} = obj.sweepVariables;
			if INDEXED
				values{i} = values{i}(index);
			end
        case 23
            % serializesweepvariables
            values{i} = [ {obj.sweepVariables.varString}.' {obj.sweepVariables.varUnit}.' ];
        case 24
            % resampling
            values{i} = obj.resampling;
        case 25
            % serializeresampling
            values{i} = [obj.resampling.varNames(:), obj.resampling.resampleExp(:)];
		end
	end
end

if ISCHAR
	values = values{1};
end

if ALLPROPS
	values = cell2struct(values, valid_props,2);
end


%--------------------------------------------------------------------------
%
%--------------------------------------------------------------------------
function notesOut = i_getAllSweepNotes(obj)
% Check for uninitialised pointer
if ~isvalid(obj.pSweepset)
    notesOut = {};
    return
end

% Preinitialise the output cell array
notes = cell(size(obj, 3), length(obj.sweepNotes));
color = cell(size(obj, 3), length(obj.sweepNotes));

% Build up the sweep notes cell array
for i = 1:length(obj.sweepNotes)
    if any(obj.sweepNotes(i).lAppliesTo)
        % Copy the note into the notes array
        [notes{obj.sweepNotes(i).lAppliesTo, i}] = deal(obj.sweepNotes(i).noteString);
        % And the color into the color array
        [color{obj.sweepNotes(i).lAppliesTo, i}] = deal(obj.sweepNotes(i).noteColor);
    end
end

% Should we get the notes from the underlying object.
if isa(obj.pSweepset.info, 'sweepsetfilter') && isempty(obj.defineTests)
    parentNotes = obj.pSweepset.get('notes');
    notes = [parentNotes(:, 1) notes];
    color = [parentNotes(:, 2) color];
end

% Create the output cell array
numNotes = size(notes, 1);
notesOut = cell(numNotes, 2);
% Concatenate all the sweeps together (note strvcat just calls char)
for i = 1:numNotes
    notesOut{i, 1} = char(notes{i, :});
    notesOut{i, 2} = vertcat(color{i, :});
end