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

    function OK = isSweepsetStruct(ss, in)
%ISSWEEPSETSTRUCT Check whether a sweepset structure is valid
%
%  ISSWEEPSETSTRUCT(SS, STRUCT) returns true if STRUCT is a structure that
%  contains the correct data for converting it to a sweepset.

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


OK = 0;
if ~isstruct(in)
    return
end

% Are all the required fields there
fields = fieldnames(in);
requiredFields = {'varNames' 'data'};
if ~all(ismember(requiredFields, fields))
    return
end

% Is data double
if ~isnumeric(in.data)
    return
end

% Is varNames a cell array of strings and of the correct size
if ~iscellstr(in.varNames) || size(in.data, 2)~=length(in.varNames)
    return
end

% Is varUnits a cell array of strings and of the correct size
if isfield(in, 'varUnits') && ~isempty(in.varUnits) ...
        && (~iscellstr(in.varUnits) || size(in.data, 2)~=length(in.varUnits))
    return
end

% Is varDescriptions a cell array of strings and of the correct size
if isfield(in, 'varDescriptions') && ~isempty(in.varDescriptions) ...
        && (~iscellstr(in.varDescriptions) || size(in.data, 2)~=length(in.varDescriptions))
    return
end

% Is comment a string
if isfield(in, 'comment') ...
        && (~ischar(in.comment))
    return
end

% Is filename a string
if isfield(in, 'filename') ...
        && (~ischar(in.filename))
    return
end

OK = 1;