www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbctree/@wksptreenode/wksptreenode.m
function node = wksptreenode( tree, name, data, index ) % mbctree.wksptreenode class constructor % Copyright 2006-2015 The MathWorks, Inc. [Type, TypeName] = i_getDataType(data); % Possibility that there is some crazy overload of size (java?) try Size = size(data); if isempty(Size) sizeStr = ''; else sizeStr = sprintf('%d x ', Size); sizeStr = sizeStr(1:end-3); end catch sizeStr = '?'; end Name = [name ' (' sizeStr ' ' TypeName ')']; % Call the inherited constructor node = mbctree.wksptreenode; treenode(node,... 'Tree', tree,... 'Size', Size,... 'Type', Type,... 'TypeName', TypeName,... 'Name', Name,... 'VarName', name,... 'ChildIndex', index ); % Now fill out the children of this node createChildren( node, data, tree ); %------------------------------------------------------------------------ function [type, typeName] = i_getDataType(data) % Here are the rules - Just a possibility that some of these calls will % cause an exception try typeName = class(data); if (isnumeric(data) || islogical(data) || iscategorical(data)) && ismatrix(data) if any(size(data) == 1) type = 'VECTOR'; else type = 'ARRAY'; end elseif isstruct(data) if numel(data) == 1 if isSweepsetStruct(sweepset, data) type = 'SSSTRUCT'; typeName = 'MBC data structure'; else type = 'STRUCT'; end else type = 'STRUCTARRAY'; end elseif iscell(data) type = 'CELL'; elseif istable(data) type = upper(class(data)); else type = 'UNKNOWN'; end catch ME type = 'UNKNOWN'; end