這是一個本地功能。向下滾動以查看它。
每當你看到一個不熟悉的功能時,輸入which
,然後輸入函數名稱來檢查它是否是Matlab函數;如果是,請輸入help
以獲取有關如何使用它的更多信息,如果不是,那麼您需要在代碼中查找它。
此外,Matlab的內置函數在它們的命名(AFAIK)中不使用下劃線,所以您可能無法獲得MathWorks提供的功能。
從鏈接文件:
function [criteria,P,n] = parse_inputs(tr,numLeaves,varargin)
% Parse the varargin parameter/value inputs
% Check that we have the right number of PVP inputs
if rem(numel(varargin),2)~= 0
error('Bioinfo:phytree:cluster:IncorrectNumberOfArguments',...
'Incorrect number of arguments to %s.',mfilename);
end
% The allowed inputs
okargs = {'criterion','distances','maxclust'};
% Set default values
P = squareform(pdist(tr)); % Pairwise distances, stored in square form
% since it will be indexed by row and columns
n = inf; % default maximum number of clusters
criteria = 'm'; % maximum is default criteria
for j=1:2:numel(varargin)-1
[k, pval] = bioinfoprivate.pvpair(varargin{j}, varargin{j+1}, okargs, ['phytree:' mfilename]);
switch(k)
case 1 % 'criterion'
crits = {'maximum','average','median','silhouette','gain','ratio'};
crit = strmatch(lower(pval),crits);
if isempty(crit)
error('Bioinfo:phytree:cluster:NotValidCriterion',...
'Not a valid criterion.')
elseif numel(crit)>1
error('Bioinfo:phytree:cluster:AmbiguousCriterion',...
'Ambiguous criterion.')
else
codes = 'madsgr';
criteria = codes(crit);
end
case 2 % 'distances'
if isnumeric(pval) && isequal(size(pval),[numLeaves,numLeaves]) && all(~diag(pval)) && isequal(pval,pval')
P = pval;
elseif isnumeric(pval) && isvector(pval) && numel(pval)==(numLeaves*(numLeaves-1)/2)
P = squareform(pval);
else
error('Bioinfo:phytree:cluster:InvalidDistances',...
'DISTANCES must be compatible to the output of SEQPDIST, PDIST, or PHYTREE/PDIST.')
end
case 3 % 'maxclust'
if ~isnumeric(pval) || ~isscalar(pval) || rem(pval,1) || pval<1
error('Bioinfo:phytree:cluster:InvalidMaxClust',...
'MAXCLUST must be a positive integer.')
end
n = pval;
end
end
你在傳遞什麼參數? 'varargin'表示之後有可選變量。 'varargin {:}'將所有這些變量輸入到'cluster'函數中。 – krisdestruction
我還應該注意''varargin'是一個包含這些參數的單元格 – krisdestruction
'parse_input'是一個[本地函數](http://es.mathworks.com/help/matlab/matlab_prog/local-functions.html)。它在文件'cluster.m'的末尾定義。 –